]> granicus.if.org Git - cronie/commitdiff
On some machines the power supply is named ADP0.
authorTomas Mraz <tmraz@fedoraproject.org>
Mon, 5 Sep 2016 08:54:08 +0000 (10:54 +0200)
committerTomas Mraz <tmraz@fedoraproject.org>
Mon, 5 Sep 2016 08:54:08 +0000 (10:54 +0200)
contrib/0anacron

index 72a613d1b4d36fd0107a7f590ee323415406b32e..027e8b711a9cc6fa0c4e5f9e4a3d273ed363c9b2 100644 (file)
@@ -8,7 +8,20 @@ if [ `date +%Y%m%d` = "$day" ]; then
 fi
 
 # Do not run jobs when on battery power
-if [ `cat /sys/class/power_supply/AC/online 2>/dev/null`x = 0x ]; then
+online=1
+for psupply in AC ADP0 ; do
+    sysfile="/sys/class/power_supply/$psupply/online"
+
+    if [ -f $sysfile ] ; then
+        if [ `cat $sysfile 2>/dev/null`x = 1x ]; then
+            online=1
+            break
+        else
+            online=0
+        fi
+    fi
+done
+if [ $online = 0 ]; then
     exit 0
 fi
 /usr/sbin/anacron -s