User:Spoiledbroth/obend.sh
From Openbox
< User:Spoiledbroth(Difference between revisions)
Spoiledbroth (Talk | contribs) (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>.....") |
Spoiledbroth (Talk | contribs) 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 | + | 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 | ||
− | |||
− | + | PROGNAME=${0} | |
case $1 in | case $1 in | ||
shutdown) | shutdown) | ||
− | + | openbox --exit & | |
+ | systemctl poweroff | ||
;; | ;; | ||
reboot) | 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 | 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