mirror of
https://github.com/pigmonkey/spark.git
synced 2026-01-22 18:14:16 +00:00
monitor AC status rather than battery status
If you set a charging threshold on the battery, you may bounce between charging and discharging while still on AC. The profile only needs to change when AC is disconnected. If the battery is discharging, but AC is connected, don't switch to a power-saving profile. I think.
This commit is contained in:
parent
89ee8d7360
commit
3dd640ed31
1 changed files with 3 additions and 2 deletions
5
roles/laptop/files/power_monitor.sh
Normal file → Executable file
5
roles/laptop/files/power_monitor.sh
Normal file → Executable file
|
|
@ -5,6 +5,7 @@
|
|||
BAT=$(echo /sys/class/power_supply/BAT*)
|
||||
BAT_STATUS="$BAT/status"
|
||||
BAT_CAP="$BAT/capacity"
|
||||
AC_STATUS=/sys/class/power_supply/ACAD/online
|
||||
LOW_BAT_PERCENT=50
|
||||
|
||||
AC_PROFILE="desktop"
|
||||
|
|
@ -19,7 +20,7 @@ prev=0
|
|||
|
||||
while true; do
|
||||
# read the current state
|
||||
if [[ $(cat "$BAT_STATUS") == "Discharging" ]]; then
|
||||
if [[ $(cat "$AC_STATUS") == "0" ]]; then
|
||||
if [[ $(cat "$BAT_CAP") -gt $LOW_BAT_PERCENT ]]; then
|
||||
profile=$BAT_PROFILE
|
||||
else
|
||||
|
|
@ -39,5 +40,5 @@ while true; do
|
|||
prev=$profile
|
||||
|
||||
# wait for the next power change event
|
||||
inotifywait -qq "$BAT_STATUS" "$BAT_CAP"
|
||||
inotifywait -qq "$AC_STATUS" "$BAT_CAP"
|
||||
done
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue