Troubleshooters.Com and T.C Linux Library Present

Changing a Terminal Icon
Copyright (C) 2008 by Steve Litt
[ Linux Library | Troubleshooters.Com| Email Steve Litt | Copyright Notice ]


Obviously, you use this document at your own risk. I am not responsible for any damage or injury caused by your use of this document, or caused by errors and/or omissions in this document. If that's not acceptable to you, you may not use this document. By using this document you are accepting this disclaimer.

Why Change the Icon?

If you've read the January 2008 Linux Productivity Magazine, you know I created a front end, to the mplayer music player, using UMENU and a filepicker and record picker. In an X environment it runs in a terminal like xtermaterm, or rxvt.

Here's the problem. I'm the kind of guy who runs 20 apps on each of several virtual desktops. If I run my music player in aterm, my icon looks like every other aterm icon (aterm icon). If I run it in xterm, my icon looks like every other xterm icon (xterm icon). It gets pretty old clicking through 7 or 8 identical icons to find the music player. I want a different icon (musicplayer icon) to identify the music player.

One could argue I could change the terminal's title using command line arguments for aterm or xterm. I do that, but if you have more than maybe 10 icons on the taskbar, the titles aren't displayed -- you must choose by icon alone.

It would be nice if xterm, aterm and rxvt had command line arguments to change the displayed icon. My research tells me that isn't an option -- the icon must be changed at the window manager level. So I changed it on my IceWM installation.

The IceWM-Centric Way

Here's the IceWM-centric way to change a terminal's Icon:

  1. Create a new name for the terminal
  2. Create icons for the new terminal name
  3. Add the new terminal name's icon to ~/.icewm/winoptions
  4. Restart IceWM
  5. Test

Create a new name for the terminal

There's an unchangeable relationship between terminal names and their icons. You must therefore create a new terminal name. Use a symbolic link:
ln -s /usr/bin/xterm /data/scripts/musicterm
In the preceding, assume that /data/scripts/musicterm is on the executable path and in a place that's backed up and not overwritten by Linux installations or other installations. This way, whenever you type musicterm at the command prompt, it will run xterm, but IceWM will look for an icon (and other features if applicable) based on the name musicterm.

Create icons for the new terminal name

Find where the icons are kept. On Mandriva 2007 they're .xpm files in the /usr/local/share/icewm/icons directory:
[slitt@mydesk icons]$ pwd
[slitt@mydesk icons]$ ls -l
total 38
-rw-r--r-- 1 root root 405 Dec 3 2006 app_16x16.xpm
-rw-r--r-- 1 root root 1237 Dec 3 2006 app_32x32.xpm
-rw-r--r-- 1 root root 2245 Dec 3 2006 emacs_16x16.xpm
-rw-r--r-- 1 root root 6555 Dec 3 2006 emacs_32x32.xpm
-rw-r--r-- 1 root root 436 Dec 3 2006 file_16x16.xpm
-rw-r--r-- 1 root root 1268 Dec 3 2006 file_32x32.xpm
-rw-r--r-- 1 root root 1294 Dec 3 2006 folder_16x16.xpm
-rw-r--r-- 1 root root 2141 Dec 3 2006 folder_32x32.xpm
-rw-r--r-- 1 root root 405 Dec 3 2006 fte_16x16.xpm
-rw-r--r-- 1 root root 1252 Dec 3 2006 fte_32x32.xpm
-rw-r--r-- 1 root root 436 Dec 3 2006 java_16x16.xpm
-rw-r--r-- 1 root root 1268 Dec 3 2006 java_32x32.xpm
-rw-r--r-- 1 root root 495 Dec 3 2006 vim_16x16.xpm
-rw-r--r-- 1 root root 1327 Dec 3 2006 vim_32x32.xpm
-rw-r--r-- 1 root root 2671 Dec 3 2006 vim_48x48.xpm
-rw-r--r-- 1 root root 1353 Dec 3 2006 xterm_16x16.xpm
-rw-r--r-- 1 root root 2185 Dec 3 2006 xterm_32x32.xpm
[slitt@mydesk icons]$

Create directory ~/.icewm/icons. Copy xterm_16x16.xpm and xterm_32x32.xpm into your ~/.icewm/icons directory, renaming them musicterm_16x16.xpm and musicterm_32x32.xpm. Now use Gimp to change them to an instantly distinguishable icon. I made mine look like a red note on a black clef, like this: musicplayer icon. Now you have the icons you want to represent your new terminal name. Now you need to associate the icon with the new terminal name. Read on...

Add the new terminal name's icon to ~/.icewm/winoptions

In IceWM, the association between program names and icons is kept in /usr/local/share/icewm/winoptions, which can be overridden, on a line by line basis, by ~/.icewm/winoptions, which may or may not exist, depending on what mods you've already made to your IceWM user config. To suitably modify ~/.icewm/winoptions, execute these commands:
touch ~/.icewm/winoptions
echo musicterm.icon: playmusic >> ~/.icewm/winoptions
The first line creates the file if it doesn't yet exist, while the second line puts the terminal name/icon association into the file. IceWM is now configured to display the new program name with the new icon, but not until you restart IceWM...

Restart IceWM

Use the start menu to restart IceWM, by "changing" the theme to its current setting. In other words, assuming the current theme is icedesert, do the following:
Your windows and screen decorations will vanish for a second and then reappear. The last to reappear will be the taskbar. Once the taskbar reappears, you know IceWM has been restarted, and it's time to test your new association.


Do this:
musicterm -e vi
The preceding runs CLI mode Vim (or plain vi depending on distro) in a new terminal called with the musicterm name. Look at the icon in the window's titlebar -- it should be your new icon. Likewise, the new window's entry on the taskbar should have the new icon.

Now try a more real-world test:
 musicterm +sb -bg darkblue -fg yellow -n Music -T Music -e vi
The preceding creates a terminal window with no scrollbars, yellow on darkblue, whose name is "Music" on the titlebar, in the taskbar, and in the window list you get with Alt+Tab. Once that works, all you need to do is substitute the command you want to run in the terminal for vi in the preceding command.

See also: [ Linux Library | Troubleshooters.Com| Email Steve Litt | Copyright Notice ]

Copyright (C)2008 by Steve Litt. -- Legal