From eb61134f2912726f0809f2c9a983a9e2b8d499fe Mon Sep 17 00:00:00 2001 From: Jacob Kiers Date: Thu, 25 Sep 2014 10:07:51 +0200 Subject: [PATCH] First make sure that a battery is present. Signed-off-by: Jacob Kiers --- bin/battery | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/battery b/bin/battery index 786cf30..5087d67 100755 --- a/bin/battery +++ b/bin/battery @@ -42,6 +42,10 @@ battery_status() case $(uname -s) in "Linux") BATPATH=${BATPATH:-/sys/class/power_supply/BAT0} + if [ ! -d $BATPATH ]; then + exit 0 + fi + STATUS=$BATPATH/status [ "$1" = `cat $STATUS` ] || [ "$1" = "" ] || return 0 if [ -f "$BATPATH/energy_full" ]; then