neodotfiles/user/.config/suckless/dmenu/scripts/dmenu_power

60 lines
1.8 KiB
Text
Raw Normal View History

2022-12-20 00:15:21 +00:00
#!/usr/bin/env bash
# ***This script was made by Clay Gomera (Drake)***
# - Description: A simple power menu dmenu script
# - Dependencies: dmenu, power-profiles-daemon
## OPTIONS ##
2023-06-24 17:00:22 +00:00
option1=" Logout"
option2=" Reboot"
option3=" Power off"
option4="󰒲 Suspend"
option5=" Lock"
option6=" Change power profile"
option7=" Cancel"
2022-12-20 00:15:21 +00:00
options="$option1\n$option2\n$option3\n$option4\n$option5\n$option6\n$option7"
## POWER PROFILE OPTIONS ##
2023-06-24 17:00:22 +00:00
pwr1="󰓅 Performance"
pwr2="󰾅 Balanced"
pwr3="󰾆 Power Saver"
pwr4=" Cancel"
2022-12-20 00:15:21 +00:00
pwrs="$pwr1\n$pwr2\n$pwr3\n$pwr4"
## MAIN ACTION COMMAND ##
2023-06-24 17:00:22 +00:00
action=$(echo -e "$options" | dmenu -i -p " Power Options")
2022-12-20 00:15:21 +00:00
case "$action" in
$option1*)
pkill X;;
$option2*)
systemctl reboot;;
$option3*)
systemctl poweroff;;
$option4*)
slock systemctl suspend;;
$option5*)
slock;;
$option6*)
currentpwr=$(powerprofilesctl get)
2023-06-24 17:00:22 +00:00
if [ "$currentpwr" = "performance" ]; then
currentpwr="$pwr1"
elif [ "$currentpwr" = "balanced" ]; then
currentpwr="$pwr2"
elif [ "$currentpwr" = "power-saver" ]; then
currentpwr="$pwr3"
fi
pwraction=$(echo -e "$pwrs" | dmenu -i -p " Power Profile Menu - Currently set to: ${currentpwr}")
2022-12-20 00:15:21 +00:00
case "$pwraction" in
$pwr1*)
2023-06-24 17:00:22 +00:00
powerprofilesctl set performance && notify-send "Power profile switched to performance";;
2022-12-20 00:15:21 +00:00
$pwr2*)
2023-06-24 17:00:22 +00:00
powerprofilesctl set balanced && notify-send "Power profile switched to balanced";;
2022-12-20 00:15:21 +00:00
$pwr3*)
2023-06-24 17:00:22 +00:00
powerprofilesctl set power-saver && notify-send "Power profile switched to power saver";;
2022-12-20 00:15:21 +00:00
$pwr4*)
exit 0
esac;;
$option7*)
exit 0
esac