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

59 lines
1.6 KiB
Text
Raw Normal View History

2022-07-01 06:06:16 +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
2022-07-01 06:06:16 +00:00
## OPTIONS ##
option1=" Logout"
option2=" Reboot"
option3=" Power off"
option4="💤 Suspend"
option5="🔒 Lock"
option6="🔋 Change power profile"
option7="❌Cancel"
2022-07-01 06:06:16 +00:00
## 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"
2022-07-01 06:06:16 +00:00
## MAIN ACTION COMMAND ##
action=$(echo -e "$options" | dmenu -b -i -p " ")
case "$action" in
$option1*)
whoami | xargs -I % sh -c 'pkill -KILL -u %';;
$option2*)
2022-07-16 18:29:15 +00:00
systemctl reboot;;
2022-07-01 06:06:16 +00:00
$option3*)
2022-07-16 18:29:15 +00:00
systemctl poweroff;;
2022-07-01 06:06:16 +00:00
$option4*)
betterlockscreen -l &
sleep 2
2022-07-16 18:29:15 +00:00
systemctl suspend;;
2022-07-01 06:06:16 +00:00
$option5*)
betterlockscreen -l;;
$option6*)
currentpwr=$(powerprofilesctl get)
pwraction=$(echo -e "$pwrs" | dmenu -b -i -p "Current profile is: ${currentpwr} | Select profile:")
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*)
2022-07-01 06:06:16 +00:00
exit 0
esac