neodotfiles/user/.config/rofi/scripts/rofi_power

69 lines
2 KiB
Text
Raw Normal View History

2022-09-13 01:06:55 +00:00
#!/usr/bin/env bash
# ***This script was made by Clay Gomera (Drake)***
# - Description: A simple power menu rofi script
2023-06-20 14:29:23 +00:00
# - Dependencies: rofi, power-profiles-daemon, swaylock
#
## MENU PROMPT ##
menu="rofi -dmenu -i -p"
## CURRENT WALLPAPER FOR LOCKSCREEN ##
currwall=$(tail --l 1 "$HOME/.wbg" | awk '{print $3}')
2022-09-13 01:06:55 +00:00
## OPTIONS ##
2023-06-20 14:29:23 +00:00
option1=" Logout"
option2=" Reboot"
2022-12-08 03:13:08 +00:00
option3=" Power off"
2023-06-20 14:29:23 +00:00
option4="󰒲 Suspend"
option5=" Lock"
option6=" Change power profile"
2023-02-20 00:41:01 +00:00
option7=" Cancel"
options="$option1\n$option2\n$option3\n$option4\n$option5\n$option6\n$option7"
## POWER PROFILE OPTIONS ##
2023-06-20 14:29:23 +00:00
pwr1="󰓅 Performance"
pwr2="󰾅 Balanced"
pwr3="󰾆 Power Saver"
2023-02-20 00:41:01 +00:00
pwr4=" Cancel"
pwrs="$pwr1\n$pwr2\n$pwr3\n$pwr4"
2022-09-13 01:06:55 +00:00
## MAIN ACTION COMMAND ##
2023-06-20 14:29:23 +00:00
action=$(echo -e "$options" | $menu "  Power Options ")
2022-09-13 01:06:55 +00:00
case "$action" in
2023-06-20 14:29:23 +00:00
$option1)
pkill Hyprland;;
$option2)
2022-09-15 03:42:36 +00:00
systemctl reboot || loginctl reboot;;
2023-06-20 14:29:23 +00:00
$option3)
2022-09-15 03:42:36 +00:00
systemctl poweroff || loginctl poweroff;;
2023-06-20 14:29:23 +00:00
$option4)
swaylock -i "$currwall" &
sleep 0.1
systemctl suspend;;
$option5)
swaylock -i "$currwall";;
$option6)
2023-02-20 00:41:01 +00:00
currentpwr=$(powerprofilesctl get)
if [ "$currentpwr" = "performance" ]; then
2023-06-20 14:29:23 +00:00
currentpwr="$pwr1"
2023-02-20 00:41:01 +00:00
elif [ "$currentpwr" = "balanced" ]; then
2023-06-20 14:29:23 +00:00
currentpwr="$pwr2"
elif [ "$currentpwr" = "power-saver" ]; then
currentpwr="$pwr3"
2023-02-20 00:41:01 +00:00
fi
2023-06-20 14:29:23 +00:00
pwraction=$(echo -e "$pwrs" | $menu "  Power Profile Menu - Currently set to: ${currentpwr} ")
2023-02-20 00:41:01 +00:00
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;;
2023-06-20 14:29:23 +00:00
$option7)
2022-09-13 01:06:55 +00:00
exit 0
esac