Ubuntu – How to suppress or disable the shutdown option from indicator menu or shutdown dialog


My goal is to allow user only to restart the system, and deny any shutdown (suspend, hibernate). I am running unity-2d.

I 've managed to deny suspend and hibernate with polkit policy files like explained in How to disable shutdown/reboot/suspend/hibernate?

I observed that is has somehow disable shutdown abilities, but hasn't removed "shutdown" entry from the indicator panel menu neither as well as the "shutdown…" button from the shutdown dialog. Pressing shutdown button at this point restarts lightdm, returning to the login screen.

My goal is to remove any "shutdown" action and button.

So, I 've added an ovveride file in /usr/share/glib-2.0/schemas that contains some rules:

suppress-shutdown-menuitem = true

(all suppress-*-menuitem has "false" value by default in the schema)

Compiling, restarting X, now there is an entry "close session…" in the indicator panel menu…: it's not what I want.

at this point, if I set another entry suppress-logout-menuitem to true I got no entry in the indicator panel menu.

Trying like this all combination doesn't give the opportunity to remove "shutdown" references/buttons without removing restart option.

All I want is to remove any reference to "shutdown" but keep a "restart" option somewhere in the indicator menu…

Thanks !

I still don't have enough data to resolve my issue. The new data is an Ubuntu maintainer ( https://bugs.launchpad.net/ubuntu/+source/indicator-session/+bug/1015558 ) admits this as an issue that is resolved in 12.10 and is not going to be resolved in the LTS branch ! From my point of view, this is cleary a regression as I didn't have any problem to do this in 10.04.

At this point, even if I manage to modify the indicator-session code, any update from the mainstream ubuntu repo will break it :/

Best Answer

In case integration to the indicator menu is not a prerequisite we can always define a custom launcher or a custom application indicator calling the follwing command to allow system restart only:

/usr/lib/indicator-session/gtk-logout-helper -r

See also: What is the command to open the shutdown dialog?