configuration.nix/packages/scripts/power-profiles.sh

37 lines
887 B
Bash
Raw Normal View History

2023-04-06 02:05:55 +05:30
#!/bin/sh
set -eu
POWER_PROFILE_FILE="$HOME/.cache/power_profile"
POWER_PROFILE="powersave"
if [ -f "$POWER_PROFILE_FILE" ]; then
POWER_PROFILE="$(<$POWER_PROFILE_FILE)"
fi
case "$1" in
"toggle")
if [ "$POWER_PROFILE" == "powersave" ]; then
cpupower frequency-set --governor performance > /dev/null
powerprofilesctl set performance
POWER_PROFILE="performance"
elif [ "$POWER_PROFILE" == "performance" ]; then
cpupower frequency-set --governor powersave > /dev/null
powerprofilesctl set power-saver
POWER_PROFILE="powersave"
fi
echo $POWER_PROFILE > $POWER_PROFILE_FILE
notify-send -u normal "Power Profile" "Switched to $POWER_PROFILE mode."
;;
"icon")
if [ "$POWER_PROFILE" == "powersave" ]; then
echo "󰌪"
elif [ "$POWER_PROFILE" == "performance" ]; then
echo "󰓅"
fi
;;
*)
;;
esac