Explorar o código

Add check to ensure battery is discharging before hibernating.

Drew %!s(int64=12) %!d(string=hai) anos
pai
achega
f04748155f
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      scripts/auto-hibernate.sh

+ 2 - 1
scripts/auto-hibernate.sh

@@ -1,6 +1,7 @@
 #!/bin/bash
 
+stat=$(cat /sys/class/power_supply/BAT0/uevent | grep STATUS | cut -f2 -d=)
 batperc=$(cat /sys/class/power_supply/BAT0/uevent | grep CAPACITY | cut -f2 -d=)
-if [[ $batperc -eq "2" ]]; then
+if [[ $stat -eq "Discharging" ]] && [[ $batperc -eq "2" ]]; then
   /usr/bin/systemctl hibernate
 fi