I have been banging my head against this for quite a while now. It's related to this question. I would like to find out exactly what happens when I choose to shut down my Linux box from the GUI. This seems to be poorly (if at all) documented.
Ideally, I'm hoping for a DE- and OS-agnostic answer. Barring that, I'm interested in the specific case of Mandriva 2010.1 and Debian 6.x (Squeeze) and 7.0 (Wheezy) all running Gnome. (If you're paying close attention, yes that's Gnome 2 and Gnome 3)
Basically, I would like to know which command/script/sequence of scripts is started when I press "Shut Down" or "Restart" so I can modify their behavior. Some forum posts I looked at suggest hacking
/etc/polkit-1/* but this directory structure is only a skeleton on my Debian (Squeeze) box, for example.
Can anyone help?
What I have tried so far
- Replaced the
shutdownexecutable with a script of my own. This doesn't work: when I press
shutdownGnome logs out without executing my script.
- Tried editing the Gnome 2 menu. No joy: the "Shutdown", "Log out" and "Lock Screen" options do not appear in the menu editor.
- Looked at
/usr/share/menu, nothing helpful there.
Possible avenues for the solution
straceing the GUI options (is this even possible?)
- Looking at
shutdown's source code
- Looking at
gnome-session's source code
As per my comments on the answer below, I have looked into
polkit actions under
/usr/share/polkit-1/actions/ and found (in the file
org.freedesktop.consolekit.policy) an action called
org.freedesktop.consolekit.system.stop-multiple-users that throws the message
System policy prevents stopping the system when other users are logged in
I'm thinking (due to the
org.freedesktop.* naming convention) that this is some kind of signal sent to the DM via D-BUS. Moreover, this message appears when trying to shutdown graphically while other users are logged in, so the mechanism that triggers it must be the same mechanism triggered when "Shut Down" or "Power Off" is selected from the GUI.
Can anyone confirm/refute? Is there a possibility of somehow intercepting this signal or modifying it?