I work with UNIX servers in my day job, and love having X11 on my Mac systems. Unfortunately, every now and then the Finder either crashes or is restarted for some reason. When that happens, any X11 applications minimized to the Dock disappear and can't be reactivated. You can see the application if you control-click on the X11 Dock icon, but if you select any of them, nothing happens.
I found that if I kill and restart quartz-wm then the hidden applications will reappear. Having had this happen to me several times, I came up with this quick fix. First, make a backup copy of /etc/X11/xinit/xinitrc.
Next, using sudo, edit the original, replacing this line at the bottom of the file:
exec quartz-wm
with this:
while :
do
quartz-wm
sleep 5
done
Restart X11 after you make this change. Now, the next time the Finder dies/restarts and you find yourself with missing X11 windows, either open a new xterm from X11, or launch Terminal and run this on the command line:
ps -ax | grep [q]uartz-wm | awk '{print $1}' | xargs kill
This finds the process id (pid) of quartz-wm (and skips the pid of grep) and sends it to kill. In five seconds, quartz-wm will restart and all of your missing X11 apps should reappear. If this doesn't happen, then you have stubborn quartz-wm that doesn't want to die. Just repeat, but add the -KILL (same as -9) option to kill:
ps -ax | grep [q]uartz-wm | awk '{print $1}' | xargs kill -KILL
Note: If you mess up your xinitrc file, just use Terminal.app to copy your backup back into place and try again.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20060216125211345