User:Spoiledbroth/obend.sh

From Openbox

< User:Spoiledbroth
Revision as of 15:45, 24 March 2018 by Spoiledbroth (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Small script to exit openbox and shutdown or reboot via openbox. Accepts parameters shutdown or reboot, so use it like obend.sh reboot... passing no variable simply prints a small menu with logout, reboot and poweroff options.

#!/bin/sh
# A small script to provide reboot and shutdown commands, and cleanly shut down openbox

PROGNAME=${0}
case $1 in
    shutdown)
        openbox --exit &
        systemctl poweroff
        ;;
    reboot)
        openbox --exit &
        systemctl reboot
        ;;
    *)
        echo "<openbox_pipe_menu>
                  <item label=\"Logout\">
                      <action name=\"Execute\">
                          <prompt>Are you sure you want to log off?</prompt>
                          <execute>openbox --exit</execute>
                      </action>
                  </item>
                  <item label=\"Reboot\">
                      <action name=\"Execute\">
                          <prompt>Are you sure you want to restart the computer?</prompt>
                          <execute>$PROGNAME reboot</execute>
                      </action>
                  </item>
                  <item label=\"Shut down\">
                      <action name=\"Execute\">
                          <prompt>Are you sure you want to power off the computer?</prompt>
                          <execute>$PROGNAME shutdown</execute>
                      </action>
                  </item>
              </openbox_pipe_menu>"
        ;;
esac
Personal tools