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

38
README.md Normal file
View File

@@ -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
* Wont crash if somethings 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
```

0
README.md~ Normal file
View File

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