Skip to content

Instantly share code, notes, and snippets.

@adnan360
Created August 8, 2018 11:43
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adnan360/f86012baeb4c9ca4f1af033550b03033 to your computer and use it in GitHub Desktop.
Save adnan360/f86012baeb4c9ca4f1af033550b03033 to your computer and use it in GitHub Desktop.
Simple script to create a selection menu for shutdown, reboot etc. based on rofi in dmenu mode
#!/bin/bash
# Simple script to handle a DIY shutdown menu. When run you should see a bunch of options (shutdown, reboot etc.)
#
# Requirements:
# - rofi
# - systemd, but you can replace the commands for OpenRC or anything else
#
# Instructions:
# - Save this file as power.sh or anything
# - Give it exec priviledge, or chmod +x /path/to/power.sh
# - Run it
chosen=$(echo -e "[Cancel]\nLogout\nShutdown\nReboot\nSuspend\nHibernate\nHybrid-sleep\nSuspend-then-hibernate" | rofi -dmenu -i)
# Info about some states are available here:
# https://www.freedesktop.org/software/systemd/man/systemd-sleep.conf.html#Description
if [[ $chosen = "Logout" ]]; then
jwm -exit
elif [[ $chosen = "Shutdown" ]]; then
systemctl poweroff
elif [[ $chosen = "Reboot" ]]; then
systemctl reboot
elif [[ $chosen = "Suspend" ]]; then
systemctl suspend
elif [[ $chosen = "Hibernate" ]]; then
systemctl hibernate
elif [[ $chosen = "Hybrid-sleep" ]]; then
systemctl hibernate
elif [[ $chosen = "Suspend-then-hibernate" ]]; then
systemctl suspend-then-hibernate
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment