From: Stefan Huber Date: Sat, 18 Apr 2020 22:01:29 +0000 (+0200) Subject: macros: Fix OnBattery() X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=46aa2f3bae61870b8360e8a22aa11d8786cc19d8;p=vimconf.git macros: Fix OnBattery() Avoid reading /sys file if not existent. --- diff --git a/macros.vim b/macros.vim index 5859967..046e381 100644 --- a/macros.vim +++ b/macros.vim @@ -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