#!/usr/bin/env sh #### User Options ### #### Menu Options ### power_off_btn="" reboot_btn="" lock_btn="" suspend_btn="鈴" logout_btn="" # grep -a since it assumes with our nullcodes etc that this is a binary file # grep -o to only leave the things we grep for case $(echo "$*" | grep -a -o -e "Shutdown" -e "Reboot" -e "Lockscreen" -e "Logout" -e "Suspend") in "Shutdown") systemctl poweroff ;; "Reboot") systemctl reboot ;; "Lockscreen") # Completely detach from the parent script # If in/outputs are not redirected, rofi will wait for the forked process as well. lockscreen rofi /dev/null 2>/dev/null & ;; "Logout") i3-msg exit ;; "Suspend") lockscreen rofi /dev/null 2>/dev/null & systemctl suspend ;; esac if [ -z "$*" ]; then printf "\x00prompt\x1fPower> \n" # we can use pango markup to hide text which we can then search. Neat! printf "\0markup-rows\x1ftrue\n" printf "\0filter\x1fshutdown\n" printf " %s\n" "$power_off_btn" printf " %s\n" "$reboot_btn" printf " %s\n" "$lock_btn" printf " %s\n" "$suspend_btn" printf " %s\n" "$logout_btn" fi