This commit is contained in:
MrEidam
2026-03-27 13:27:23 +01:00
commit b8c84f2e62
3 changed files with 78 additions and 0 deletions

40
power-toggle.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
# get current profile safely
current=$(powerprofilesctl get 2>/dev/null)
# get list of available profiles
available=$(powerprofilesctl list 2>/dev/null)
# fallback if command failed
if [ -z "$current" ]; then
echo "powerprofilesctl not working"
exit 1
fi
# helper function
has_profile(){
echo "$available" | grep -q "$1"
}
if [ "$current" = "performance" ]; then
if has_profile "power-saver"; then
powerprofilesctl set power-saver
else
powerprofilesctl set balanced
fi
elif [ "$current" = "power-saver" ]; then
powerprofilesctl set balanced
elif [ "$current" = "balanced" ]; then
if has_profile "performance"; then
powerprofilesctl set performance
else
powerprofilesctl set power-saver
fi
else
echo "Unknown profile: $current"
exit 1
fi