surtur
2cf6883b3c
utilizes powerprofilesctl to change states automatically based on the current battery level ref: https://www.reddit.com/r/gnome/comments/qn60lo/automatic_power_profile_selection
24 lines
570 B
Bash
Executable File
24 lines
570 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# courtesy of https://www.reddit.com/r/gnome/comments/qn60lo/automatic_power_profile_selection/
|
|
|
|
capacity=$(cat /sys/class/power_supply/BAT0/capacity)
|
|
old_capacity=$(cat /tmp/bat_capacity)
|
|
[[ "$capacity" == "$old_capacity" ]] && exit 0
|
|
|
|
echo $capacity > /tmp/bat_capacity
|
|
|
|
eval "$(cat /sys/class/power_supply/BAT0/uevent|sed -e 's/ //g')"
|
|
|
|
if [[ "$POWER_SUPPLY_STATUS" == "Discharging" ]]
|
|
then
|
|
if (( $POWER_SUPPLY_CAPACITY > 30 ))
|
|
then
|
|
powerprofilesctl set balanced
|
|
else
|
|
powerprofilesctl set power-saver
|
|
fi
|
|
else
|
|
powerprofilesctl set performance
|
|
fi
|