Wednesday, February 18, 2009

xmessage and the simple things in life

I have a slow computer. I bought it before I could grow a beard or even any back hair. Full on GNOME is usually a little too heavy, so I run everything from FVWM to Fluxbox to whatever.

I thought it would be nice to shutdown with a menu command.

The program xmessage will allow you to setup multiple buttons, each with a different number. That number will be the return code for the program. Bash (bless its little heart) will allow you to query the return code in the variable "$!". They seem like a natural fit!

I did a little visudo so that my group could call shutdown without entering a password.

%admin ALL=NOPASSWD: /sbin/shutdown

Here's the contents of my shutdown script:


xmessage -buttons "Yeah boy!":0,"Quit rushin' me...":1 "Shut this bitch down?"

if [ $? == 0 ]; then
sudo shutdown -h now