Sunday, June 9, 2019

openbox shutdown, revisited

A few years back, I wrote about the shutdown script I was using in Openbox (see: "openbox shutdown"). Lately, I've been using a similar script, but with a couple of changes that make things simpler here.

I replaced the sudo shutdown -r now and sudo shutdown -h now commands with systemctl reboot and systemctl poweroff, respectively. Not an acceptable option for systemd-haters, but oh well.

My ~/shutdown-script file in Debian Buster Openbox (again, this requires the gxmessage package) looks like this:

#!/bin/bash

gmessage "Shut down the computer?" -center -title "Take action" -font "Sans bold 10" -default "Cancel" -buttons "_Cancel":1,"_Log Out":2,"_Reboot":3,"_Shut Down":4 >/dev/null

case $? in
    1)
        echo "Exit";;
    2)
        openbox --exit;;
    3)
        systemctl reboot;;
    4)
        systemctl poweroff;;
esac

After making that file executable, I added a "shutdown" entry in my Openbox menu, using the ~/shutdown-script command.

The same script works for me in Openbox in Arch, except I had to replace the word "gmessage" with "gxmessage" in the script.

Nothing fancy, just a "Take action" message box, plain and simple:


No comments: