Skip to content

Instantly share code, notes, and snippets.

@harish2704
Created October 1, 2016 05:45
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save harish2704/25857caf89076d5a78e996df3fa6ac56 to your computer and use it in GitHub Desktop.
Save harish2704/25857caf89076d5a78e996df3fa6ac56 to your computer and use it in GitHub Desktop.
A simple commandline tool to show system Shutdown/suspend/hibernate/restart dialog. in a Linux desktop environment
#!/usr/bin/env bash
# A simple commandline tool to show system Shutdown/suspend/hibernate/restart dialog.
# this tool can be used in any modern linux desktop environemtnt provided the following packages are instaleld
# * systemd - The new system service manager
# * yad - A powerfull alternative to zenity or 'dialog' command
yad \
--on-top \
--center \
--text-align center \
--title="Ok Bro, Lets take rest" \
--text="What to do??" \
--button="_Shutdown!system-shutdown:10" \
--button="S_leep!gnome-session-suspend:11" \
--button="_Restart!system-restart:12" \
--button="_Hibernate!gnome-session-hibernate:13"
case "$?" in
10)
echo 'Shutdown'
systemctl poweroff
;;
11)
echo 'Sleep'
systemctl suspend
;;
12)
echo 'Restart'
systemctl reboot
;;
13)
echo 'Hibernate'
systemctl hibernate
;;
*)
echo 'Nothing...'
esac
@harish2704
Copy link
Author

Screenshot

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment