neodotfiles/new-config/.config/rofi/scripts/rofi_power
Clay Gomera 9f8ac8a84e updated
2023-02-25 12:12:09 -04:00

70 lines
2.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# ***This script was made by Clay Gomera (Drake)***
# - Description: A simple power menu rofi script
# - Dependencies: rofi, power-profiles-daemon
#
## CURRENT WALLPAPER FOR LOCKSCREEN ##
currwall=$(tail --l 1 "$HOME/.wbg" | awk '{print $5}')
## OPTIONS ##
option1=" Logout"
option2=" Reboot"
option3=" Power off"
option4="鈴 Suspend"
option5=" Lock"
option6=" Change power profile"
option7=" Cancel"
## OPTIONS ARRAY ##
options="$option1\n$option2\n$option3\n$option4\n$option5\n$option6\n$option7"
## POWER PROFILE OPTIONS ##
pwr1=" Performance"
pwr2=" Balanced"
pwr3=" Power Saver"
pwr4=" Cancel"
## POWER PROFILES ARRAY ##
pwrs="$pwr1\n$pwr2\n$pwr3\n$pwr4"
## MAIN ACTION COMMAND ##
action=$(echo -e "$options" | rofi -dmenu -i -p "  Power Options ")
case "$action" in
$option1*)
pkill Hyprland;;
$option2*)
systemctl reboot || loginctl reboot;;
$option3*)
systemctl poweroff || loginctl poweroff;;
$option4*)
swaylock -i "$currwall" &
sleep 0.1
systemctl suspend;;
$option5*)
swaylock -i "$currwall";;
$option6*)
currentpwr=$(powerprofilesctl get)
if [ "$currentpwr" = "performance" ]; then
currentpwr=" Performance"
elif [ "$currentpwr" = "power-saver" ]; then
currentpwr=" Power Saver"
elif [ "$currentpwr" = "balanced" ]; then
currentpwr=" Balanced"
fi
pwraction=$(echo -e "$pwrs" | rofi -dmenu -i -p "  Power Profile Menu - Currently set to: ${currentpwr} ")
case "$pwraction" in
$pwr1*)
powerprofilesctl set performance && notify-send "Power profile switched to performance";;
$pwr2*)
powerprofilesctl set balanced && notify-send "Power profile switched to balanced";;
$pwr3*)
powerprofilesctl set power-saver && notify-send "Power profile switched to power saver";;
$pwr4*)
exit 0
esac;;
$option7*)
exit 0
esac