Fun with urxvt
Wednesday, May 9th, 2012I recently installed Xubuntu 12.04 LTS. Being a long time command line user I do work a lot with terminals. Xubuntu comes with xfce-terminal by default, which is quite memory hungry. It’s started via the exo wrappers, which enable you to configure different programs than the default ones. You do that via the Preferred Applications dialog menu in Settings Manager.
Rxvt is a lightweight terminal which can run in client-server mode, meaning that you start a server and every new terminal connects to it through a socket. Apart from taking up little memory, this approach further reduces the memory footprint of additional terminals. There is a downside to this – if the server process crashes, all your clients crash with it. So it goes. Urxvt is a fork of rxvt with unicode support and some other goodies. The urxvtcd program starts a server process and subsequent client processes. Below you have a comparision of the memory used by xfce-terminal, a single rxvt process and a urxvtd server process with two client terminals.
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND 1000 3187 0.3 0.7 285928 14604 pts/5 Sl+ 18:00 0:00 xfce4-terminal 1000 3177 0.1 0.1 40500 2724 pts/5 S+ 17:59 0:00 rxvt 1000 2311 0.0 0.1 41604 3484 ? S 17:05 0:00 urxvtd -q -f
The trouble is that the Preferred Aplications dialog doesn’t let run the command with arguments. I don’t know if this is a bug or a feature, but you have to resort to a bit of command line magic in order to run urxvtcd with the desired options. The first step is to set urxvtcd as the preferred terminal application and then edit the following file with your favourite editor and alter the X-XFCE-Commands line to run the program with the desired parameters:
$ vim ~/.local/share/xfce4/helpers/custom-TerminalEmulator.desktop # X-XFCE-CommandsWithParameter=urxvtcd -bg black -fg white -fn fixed +sb -tn rxvt -e "%s" X-XFCE-Commands=urxvtcd -bg black -fg white -fn fixed +sb -tn rxvt
Voilà. Now you can happily run your lightweight terminal every time you click on the Terminal emulator icons in the context menu or on the panel. Of course, this tutorial assumes that you have already installed the rxvt-unicode or the rxvt-unicode-lite package.