Browse Source

Add check to ensure battery is discharging before hibernating.

Drew 12 năm trước cách đây
mục cha
commit
f04748155f
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  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