]> git.sthu.org Git - vimconf.git/commitdiff
macros: Fix OnBattery()
authorStefan Huber <shuber@sthu.org>
Sat, 18 Apr 2020 22:01:29 +0000 (00:01 +0200)
committerStefan Huber <shuber@sthu.org>
Sat, 18 Apr 2020 22:01:29 +0000 (00:01 +0200)
Avoid reading /sys file if not existent.

macros.vim

index 58599670c737d4e4f01f920551b31a873f571155..046e381283aef870c7ebc0b50008867ff8551ecd 100644 (file)
@@ -119,7 +119,9 @@ function OnBattery()
   if has('macunix')
     return match(system('pmset -g batt'), "Now drawing from 'Battery Power'") != -1
   elseif has('unix')
-    return readfile('/sys/class/power_supply/AC/online') == ['0']
+    if filereadable('/sys/class/power_supply/AC/online')
+      return readfile('/sys/class/power_supply/AC/online') == ['0']
+    endif
   endif
   return 0
 endfunction