Initial
This commit is contained in:
38
README.md
Normal file
38
README.md
Normal 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
|
||||||
|
* 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
|
||||||
|
```
|
||||||
0
README.md~
Normal file
0
README.md~
Normal file
40
power-toggle.sh
Executable file
40
power-toggle.sh
Executable 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
|
||||||
Reference in New Issue
Block a user