Linux
Apache
MySQL
PHP

CSS
XHTML1.1
XML/RSS

Creative Commons

2008-01-24 12:49:36

Debug the TWM Menu in RHEL4

So your window manager of choice is TWM because of it's slimness and configurability. But after painstaking hour^H^H^H^Hminutes editing your .twmrc to add some applications to the menu you find that they don't work. You can click on them all you want, but they don't run. How do you debug this? TWM doesn't have a log file. Any output from the program in question goes into the abyss, never to be seen. What do you do?
Here's one solution. Assuming you made TWM your default window manager by using
> switchdesk twm
you will have a .Xclients-default file in your home directory. Let's examine that file:
#!/bin/bash # (C) 2000 Red Hat, Inc. WM="twm" WMPATH="/usr/bin /usr/X11R6/bin /usr/local/bin" for p in $WMPATH ; do [ -x $p/$WM ] && exec $p/$WM done exit 1
So, this file has the executable name of your window manager and then a list of paths where that executable may exist. Then, it checks each path, and if the executable exists there, it runs it. Simple.
After reading the TWM manpage, I found that giving TWM the -v option will spit out error messages and such to the console. That's exactly what I'm looking for. So now I just have to make TWM start with that option. My .Xclients-default file ended up having this line:
[ -x $p/$WM ] && exec "$p/$WM -v >& /home/myuser/twm.log"
In theory, that should work. It doesn't. I even slimmed it down to this:
[ -x $p/$WM ] && exec "$p/$WM -v"
and it didn't work. That's when I realized it was going to be futile to try and add the argument in this file. I had to be a little more clever.
This was going to take a wrapper script. First things first, make the line in your .Xclients-default look like this:
WM="twm-wrapper"
This way, when X starts, it will load your wrapper script, which will launch TWM with the correct arguments. So, create /usr/X11R6/bin/twm-wrapper as follows:
#!/bin/sh /usr/X11R6/bin/twm -v >& /home/myuser/twm.log
This script will run TWM in verbose mode, directing all output to a log file in your home directory. Don't forget to make this file eXecutable!
Now you can logout and log back in. TWM will have been started by your wrapper script and you'll notice a 0 size twm.log in your home directory. Try to run the bad program from your TWM menu, then check the twm.log. Any output that the program spit out will be there. Now you can debug the problem!

Back


Post a comment!

Name:
Comment: