How can I add a menu item to Openbox which launches a prompt to cancel or provide a root password, then shuts down X and the computer if the correct password was given? The question Shutting the computer down from Openbox is related, but the answer involved typing, not clicking through them menus.

The documentation suggests that one add a systemctl poweroff menu like this, but the menus do not appear to work:

<item label="Shutdown">
    <action name="Execute">
        <command>systemctl poweroff</command>

I am using Debian 7.0.


1 Answer 1


On my desktop I use the following menu items for rebooting and halting:

<item label='Shutdown'>
   <action name='Execute'>
     <command>/usr/local/bin/opBox-exit.sh halt</command>
<item label='Reboot'>
   <action name='Execute'>
     <command>/usr/local/bin/opBox-exit.sh reboot</command>

The script /usr/local/bin/opBox-exit.sh uses zenity to open a cancel-confirm-dialog and when the confirm button was pressed it executes sudo halt or sudo reboot. I configured the sudoers file so my user wouldn't have to type in a password to run halt and reboot with sudo. For me this is more convenient. Here is the full script

#!/usr/bin/env bash

if [ -z $1 ];then
   echo "Usage: $0 [reboot|halt]"
if [ $1 = reboot ];then
   zenity --question --ok-label "Reboot" --text "Reboot $HOST?" && sudo /sbin/reboot
elif [ $1 = halt ];then
   zenity --question --ok-label "Shudown" --text "Shutdown $HOST?" && sudo /sbin/halt -p

When you want a dialog for the users password I would recommend that you use gksudo halt -p instead of the whole zenity --question ... && sudo halt -p stuff. For this your user would still need to be able to execute commands via sudo. Take a look at man sudoers for more information.

gksudo is in the Debain package gksu.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .