Ubuntu – Keyboard shortcut to shutdown

shutdown

I came across Why do we need to be root in terminal for shutdown and restart? and the accepted answer has an explanation indicating that clicking on "Shutdown" in Ubuntu's dropdown menu triggers this command:

dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown

I also saw Are there any Keyboard Shortcuts to Shutdown? which suggested this code:

dbus-send --system --print-reply --system --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop

The two codes differ. (Also, I don't know why --system comes twice in second code.) Which code is appropriate for 13.10? Or is there a new code to be used?

Then I can make keyboard shortcut of this command to shutdown my computer from the keyboard instead of having to use the mouse to click on "cogwheel", "shutdown".

Best Answer

Yes, you can assign a specific, non-used key-combination as a shortcut to shut-down. To assign Ctrl+Alt+Esc (or any other key combination) as the shortcut, go to System settings > Keyboard > Shortcuts > Custom shortcut and then add a new shortcut.

The command should be

dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop

I am not pretty sure why you have --system twice in the command, but a single one works on Ubuntu 13.10(have tested, confirmed to work).

Related Question