In my current Window Maker configuration, I use xcompmgr to create some nice shadows for the windows. The problem is that xcompmgr sometimes doesn’t realize that a window has closed, and thus the shading remains while the window is actually no longer there. It is possible to “fix” this problem by reopening the window and closing it, but this is ot workable: the only workable work-around is to restart xcompmgr; since xcompmgr is small and fast, this is not a problem.
There are a number of ways to automate this…
Currently, xcompmgr is started in ~/GNUstep/Library/WindowMaker/autostart
:
xcompmgr -c -C -r 8 -l -12 -t -12 &
To make it easy to restart xcompmgr, let’s put a program around it that automatically starts the program again if it dies. Since xcompmgr does not go into the background, we can just start it up and when it exits, restart (in a loop).
With Ruby, we can do this:
#!/usr/bin/ruby # # xcompmgr2: run xcompmgr and keep it running: # permits autorestart of xcompmgr # Get rid of any programs already running... `pkill -x xcompmgr` while (1==1) do # Main program: run it! `/usr/bin/xcompmgr -c -C -r 8 -l -12 -t -12` # Catch and log unusual exitstatus... if ($?.exitstatus != 15 && $?.exitstatus != 0) then # Not good end end
If xcompmgr exits for any reason, it loops again in the infinite loop. This sort of program could be done in almost any language: certainly Perl, ksh, and PHP are up to the task (as are many others).
Thus, when xcompmgr gets confused, do this command to fix it:
pkill -x xcompmgr
The -x
option makes it so that xcompmgr is killed, and not xcompmgr2: -x
matches a command name exactly.