commit b8c84f2e62467530639981980fd25b17624076bb Author: MrEidam Date: Fri Mar 27 13:27:23 2026 +0100 Initial diff --git a/README.md b/README.md new file mode 100644 index 0000000..7706243 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# Power Profile Toggle Script + +Simple Bash script to cycle power profiles using `powerprofilesctl`. + +## Features + +* Cycles: `performance → power-saver → balanced` +* Skips unsupported modes automatically +* Won’t crash if something’s missing + +## Requirements + +* `power-profiles-daemon` + +## Install + +**Void** + +```bash +sudo xbps-install power-profiles-daemon +``` + +**Debian/Ubuntu** + +```bash +sudo apt install power-profiles-daemon +``` + +**Other** +I dunno, just use your package manager to install `power-profiles-daemon` +If your system isn't totally minimalistic then it should be pre-installed + +## Usage + +```bash +chmod +x power-toggle.sh +./power-toggle.sh +``` diff --git a/README.md~ b/README.md~ new file mode 100644 index 0000000..e69de29 diff --git a/power-toggle.sh b/power-toggle.sh new file mode 100755 index 0000000..3e1fd4d --- /dev/null +++ b/power-toggle.sh @@ -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 \ No newline at end of file