From 6bfce1a6b9f5778bbe6eff23b9104c339421ad81 Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Sun, 6 Sep 2020 18:15:51 +0200 Subject: [PATCH] Show charging status dynamically --- .bin/check-battery-level | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.bin/check-battery-level b/.bin/check-battery-level index 334e2be..b5f4c4f 100755 --- a/.bin/check-battery-level +++ b/.bin/check-battery-level @@ -5,7 +5,11 @@ GREEN='\033[0;32m' NC='\033[0m' capacityStatus=$(cat /sys/class/power_supply/BAT0/capacity) -chargingStatus=$(cat /sys/class/power_supply/AC/online) +chargingStatus="" + +if [ -f /sys/class/power_supply/AC/online ]; then + chargingStatus=$(cat /sys/class/power_supply/AC/online) +fi if [ "$chargingStatus" == "1" ]; then printf "Battery is ${GREEN}charging${NC}.\n"