OK, cstorm and anyone else interested. Here’s what I did to dynamically set the window icon –
First add the following to your ~/.fvwm/config:
# Dynamically set window Titles
*FvwmEvent: Cmd
*FvwmEvent: window_name "Exec ~/.fvwm/seticon.sh $[w.id] $[w.class] $[w.miniiconfile] '$[w.name]'"
Now make a script called seticon.sh in your ~/.fvwm directory. (Don’t forget to chmod a+x ~/.fvwm/seticon.sh). Put the following in the script:
[code]#! /bin/bash
seticon.sh win-id class iconfile title
seticon () {
# Don’t change the icon unnecessarily
if [[ $iconfile != $1 ]]; then
FvwmCommand “WindowId $winid WindowStyle MiniIcon $1”
fi
exit
}
winid=$1
class=$2
iconfile=${3##*/}
progname=${4%% }
progname=${progname##/}
Iconfile now contains the name of the icon (with the path stripped), and
progname contains the name of the program (with path and arguments
stripped).
Don’t change the icon on root consoles, or anything other than xterm
if [[ $iconfile == “tux.png” || $class != “XTerm” ]]; then exit; fi
case $progname in
vim) seticon vim.png;;
mutt) seticon mutt.png;;
man) seticon man.png;;
w3m) seticon elinks.png;;
# su) seticon tux.png;;
# add other icons here. for example
*) seticon xterm.png;;
esac
vim: set ft=sh:[/code]
Finally you might want to add the line
+ I Module FvwmEvent
somewhere to your StartFunction.
The advantage of this script is that it avoids changing the icon when not necessary (avoids the fliker). Also if you launch a vim from mutt, say then the icon is changed Further the script can easily be modified so that you can set the icon depending on the file you’re editing in Vim say
.
HTH, and thanks for the help all.
GI
[color=blue][size=75]Edit: In keeping with cstorm’s example, I made a few copy paste errors. I fixed them.[/size][/color]