power.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env bash
  2. # Simple script to handle a DIY shutdown menu. When run you should see a bunch of options (shutdown, reboot etc.)
  3. #
  4. # Requirements:
  5. # - rofi
  6. # - systemd, but you can replace the commands for OpenRC or anything else
  7. #
  8. # Instructions:
  9. # - Save this file as power.sh or anything
  10. # - Give it exec priviledge, or chmod +x /path/to/power.sh
  11. # - Run it
  12. chosen=$(echo -e "[Cancel]\nLogout\nShutdown\nReboot\nSuspend\nHibernate\nHybrid-sleep\nSuspend-then-hibernate" | rofi -dmenu -i)
  13. # Info about some states are available here:
  14. # https://www.freedesktop.org/software/systemd/man/systemd-sleep.conf.html#Description
  15. if [[ $chosen = "Logout" ]]; then
  16. jwm -exit
  17. elif [[ $chosen = "Shutdown" ]]; then
  18. systemctl poweroff
  19. elif [[ $chosen = "Reboot" ]]; then
  20. systemctl reboot
  21. elif [[ $chosen = "Suspend" ]]; then
  22. systemctl suspend
  23. elif [[ $chosen = "Hibernate" ]]; then
  24. systemctl hibernate
  25. elif [[ $chosen = "Hybrid-sleep" ]]; then
  26. systemctl hibernate
  27. elif [[ $chosen = "Suspend-then-hibernate" ]]; then
  28. systemctl suspend-then-hibernate
  29. fi