Ver código fonte

Add check to ensure battery is discharging before hibernating.

Drew 12 anos atrás
pai
commit
f04748155f
1 arquivos alterados com 2 adições e 1 exclusões
  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