From 46aa2f3bae61870b8360e8a22aa11d8786cc19d8 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Sun, 19 Apr 2020 00:01:29 +0200 Subject: [PATCH] macros: Fix OnBattery() Avoid reading /sys file if not existent. --- macros.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- 2.39.5