1

When I press the hardware power button and the login screen (or unity) is running I get a nice "are you sure you want to shutdown" message.

When I am running fluxbox, I get a software shutdown, but no message/confirmation.

Is there any way to change that? I don't mind writing the zenity script/program, I just need a place to put it.

josinalvo
  • 7,017

1 Answers1

1

From: Fluxbox Wiki - Shutdown computer with dialog

Fluxbox doesn't come with some nice eye candy way to shutdown your computer. But, if you're using GDM to log in, you can also tell it to shut down. For ease of use, a script giving you some confirmation dialog can be used.

First, we'll create a dialog:

xmessage -nearmouse -buttons No:1,Yes:0 "Really shutdown?"

There are other ways to do this, we're not bound to use xmessage here. It's an easy way, though.

If the user clicks the "no" button, nothing else needs to be done, except maybe giving him some advice on using his mouse. If he clicks on "yes", we'll shut down his computer.

To do so, we'll first tell GDM that we want to shutdown by the time fluxbox exits:

gdmflexiserver -a -c 'SET_LOGOUT_ACTION HALT'

Then, we kill fluxbox:

kill -TERM $(xprop -root _BLACKBOX_PID | awk '{print $3}')

Some string and tape adds up to a script to add to your menu:

#!/bin/sh
if xmessage -nearmouse -buttons No:1,Yes:0 "Really shutdown?"; then
  gdmflexiserver -a -c 'SET_LOGOUT_ACTION HALT'
  kill -TERM $(xprop -root _BLACKBOX_PID | awk '{print $3}')
else
  xmessage -nearmouse "Then why did you press that big red button?"
fi

Caveat: I don't use Fluxbox. Any clarifications on material on their Wiki page will have to be asked to them. I've cleaned up some of the grammar after copying their website instructions above, but it's still not perfect.


You can find a rather heated argument about the "Shutdown Button" between a user and Fluxbox (developers?) on Source Forge. At the end of the argument someone posts source code and it appears /usr/bin/shutdown might be where you want to put in the hook. ie Create your own /usr/bin/shutdown which calls /usr/bin/shutdown2 which is the original copy.