Sounds familiar? You want to power off your computer. So you exit the X session.
And now you have to choose "shutdown" from some menu of your display manager, or,
even worse, you have to log on as root on a text console an type "halt". This
really sucks. So i've written this tiny script.
First it sends an "exit session" command to kwm. It could simply kill the
window manager, but then session management would not work. If you are not using
kde, then you have to adopt the script (e.g., "killall fvwm2"). So now
you are logged off.
Then it checks, if anybody still is logged on (on a text console or via telnet
or whatever). If not, then the system is halted (or rebooted).
You can use it on the text console or in a telnet session as well, as it will
notice, that your terminal line is the only used one. So you might start using
"halten" to log off; if nobody else is on your machine, then it will shut down.
I created a hotkey link (alt-ctrl-down) to "halten" on my system, so shutting
down the machine takes not more than pressing three keys at once.
Download & Install
as /usr/local/sbin/halten or whereever and make sure, that it is in your PATH.
There is also another version
which can shut down other computers which act as X terminals for remote logins
You have to add the following to your /etc/sudoers (install sudo, if you don't
have it already):
#the users, which are allowed to shutdown the machine
#allow halten to gain root privileges