Last active
August 21, 2016 12:55
-
-
Save wzpan/9408566 to your computer and use it in GitHub Desktop.
A GUI Shutdown dialog.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ACTION=`zenity --width=90 --height=200 --list --radiolist --text="Select logout action" --title="Logout" --column "Choice" --column "Action" TRUE Shutdown FALSE Reboot FALSE LockScreen FALSE Suspend` | |
if [ -n "${ACTION}" ];then | |
case $ACTION in | |
Shutdown) | |
zenity --question --text "Are you sure you want to halt?" && gksudo halt | |
## or via ConsoleKit | |
# dbus-send --system --dest=org.freedesktop.ConsoleKit.Manager | |
# /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop | |
;; | |
Reboot) | |
zenity --question --text "Are you sure you want to reboot?" && gksudo reboot | |
## Or via ConsoleKit | |
# dbus-send --system --dest=org.freedesktop.ConsoleKit.Manager | |
# /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart | |
;; | |
Suspend) | |
#gksudo pm-suspend | |
dbus-send --system --print-reply --dest=org.freedesktop.Hal | |
/org/freedesktop/Hal/devices/computer | |
org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0 | |
# HAL is deprecated in newer systems in favor of UPower etc. | |
# dbus-send --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend | |
;; | |
LockScreen) | |
slock | |
# Or gnome-screensaver-command -l | |
;; | |
esac | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment