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
|
|
|
|
# - Dependencies: rofi, power-profiles-daemon
|
|
|
|
|
|
|
|
## OPTIONS ##
|
|
|
|
option1="(L) Logout"
|
|
|
|
option2="(R) Reboot"
|
|
|
|
option3="(P) Power off"
|
|
|
|
option4="(S) Suspend"
|
|
|
|
option5="(K) Lock"
|
|
|
|
option6="(C) Change power profile"
|
|
|
|
option7="(X) Cancel"
|
|
|
|
|
|
|
|
## OPTIONS ARRAY ##
|
|
|
|
options="$option1\n$option2\n$option3\n$option4\n$option5\n$option6\n$option7"
|
|
|
|
|
|
|
|
## POWER PROFILE OPTIONS ##
|
|
|
|
pwr1="(P) Performance"
|
|
|
|
pwr2="(B) Balanced"
|
|
|
|
pwr3="(S) Power Saver"
|
|
|
|
pwr4="(X) Cancel"
|
|
|
|
|
|
|
|
## POWER PROFILES ARRAY ##
|
|
|
|
pwrs="$pwr1\n$pwr2\n$pwr3\n$pwr4"
|
|
|
|
|
|
|
|
## MAIN ACTION COMMAND ##
|
2022-09-13 01:37:03 +00:00
|
|
|
action=$(echo -e "$options" | rofi -dmenu -b -l 7 -i -p " ")
|
2022-09-13 01:06:55 +00:00
|
|
|
case "$action" in
|
|
|
|
$option1*)
|
2022-09-14 00:44:31 +00:00
|
|
|
pkill X;;
|
2022-09-13 01:06:55 +00:00
|
|
|
$option2*)
|
2022-09-14 00:44:31 +00:00
|
|
|
loginctl reboot;;
|
2022-09-13 01:06:55 +00:00
|
|
|
$option3*)
|
2022-09-14 00:44:31 +00:00
|
|
|
loginctl poweroff;;
|
2022-09-13 01:06:55 +00:00
|
|
|
$option4*)
|
|
|
|
betterlockscreen --suspend;;
|
|
|
|
$option5*)
|
|
|
|
betterlockscreen -l;;
|
|
|
|
$option6*)
|
|
|
|
currentpwr=$(powerprofilesctl get)
|
2022-09-13 01:37:03 +00:00
|
|
|
pwraction=$(echo -e "$pwrs" | rofi -dmenu -b -l 3 -i -p "Current profile is: ${currentpwr} | Select profile:")
|
2022-09-13 01:06:55 +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;;
|
|
|
|
$option7*)
|
|
|
|
exit 0
|
|
|
|
esac
|