User:Spoiledbroth/obend.sh

From Openbox

< User:Spoiledbroth(Difference between revisions)
Jump to: navigation, search
(Created page with "Small script to exit openbox and shutdown or reboot via openbox. Accepts parameters <code>shutdown</code> or <code>reboot</code>, so use it like <code>obend.sh reboot</code>.....")
 
m
 
Line 1: Line 1:
Small script to exit openbox and shutdown or reboot via openbox. Accepts parameters <code>shutdown</code> or <code>reboot</code>, so use it like <code>obend.sh reboot</code>... passing no variable simply exits openbox.
+
Small script to exit openbox and shutdown or reboot via openbox. Accepts parameters <code>shutdown</code> or <code>reboot</code>, so use it like <code>obend.sh reboot</code>... passing no variable simply prints a small menu with logout, reboot and poweroff options.
  
 
<pre>
 
<pre>
 
#!/bin/sh
 
#!/bin/sh
 
 
# A small script to provide reboot and shutdown commands, and cleanly shut down openbox
 
# A small script to provide reboot and shutdown commands, and cleanly shut down openbox
# https://askubuntu.com/questions/454039/what-command-is-executed-when-shutdown-from-the-graphical-menu-in-14-04
 
  
openbox --exit &
+
PROGNAME=${0}
 
case $1 in
 
case $1 in
 
     shutdown)
 
     shutdown)
         dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 "org.freedesktop.login1.Manager.PowerOff" boolean:true
+
         openbox --exit &
 +
        systemctl poweroff
 
         ;;
 
         ;;
 
     reboot)
 
     reboot)
         dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 "org.freedesktop.login1.Manager.Reboot" boolean:true
+
         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
 
esac
 
</pre>
 
</pre>

Latest revision as of 15:45, 24 March 2018

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