Skip to content

Instantly share code, notes, and snippets.

@blueyed
Created July 5, 2015 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blueyed/84a578b575ef07e9635c to your computer and use it in GitHub Desktop.
Save blueyed/84a578b575ef07e9635c to your computer and use it in GitHub Desktop.
#!/bin/sh
# close stdin
exec <&-
# ACTION=$(zenity --title "Select logout action" --text "How to quit?" --height=250 --list \
# --hide-header --hide-column=1 --column=action --column=desc \
# suspend "Suspend" \
# hybrid-sleep "Hybrid sleep" \
# hibernate "Hibernate" \
# reboot "Reboot" \
# shutdown "Shutdown" \
# switch-user "Switch user" \
# logout "Logout" \
# lock "Lock screen")
# ACTION=$(printf 'suspend\nhybrid-sleep\nhibernate\nreboot\nshutdown\nswitch-user\nlogout\nlock' \
# | dmenu -p "How do you want to quit?")
ACTION=$(printf 'suspend|hybrid-sleep|hibernate|reboot|shutdown|switch-user|logout|lock|abort|' \
| rofi -dmenu -sep '|' -p "How do you want to quit? " -only-match)
if [ -n "${ACTION}" ];then
case $ACTION in
switch-user)
# Lightdm: detect via XDG_SEAT_PATH
dm-tool switch-to-greeter
# for gdm: gdmflexiserver --startnew
;;
hybrid-sleep) systemctl hybrid-sleep ;;
suspend)
systemctl suspend
/usr/bin/slock
;;
hibernate) systemctl hibernate ;;
reboot)
zenity --question --text "Are you sure?" \
&& systemctl reboot ;;
shutdown)
zenity --question --text "Are you sure?" \
&& systemctl poweroff ;;
logout)
zenity --question --text "Are you sure?" \
&& gnome-session-quit --logout --no-prompt ;;
lock) slock ;;
abort) ;;
esac
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment