From a250278454a0e040198673cca483a977b5139ca6 Mon Sep 17 00:00:00 2001 From: Filip Rojek Date: Fri, 24 Feb 2023 12:00:57 +0100 Subject: [PATCH] battery script updated --- dwmblocks_scripts/dwm_battery | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dwmblocks_scripts/dwm_battery b/dwmblocks_scripts/dwm_battery index 9e44acc..a7e994d 100755 --- a/dwmblocks_scripts/dwm_battery +++ b/dwmblocks_scripts/dwm_battery @@ -3,5 +3,21 @@ prct=$(acpi | grep 'Discharging' | awk '{print $4}' | sed 's/,//') batid=$(acpi | grep 'Discharging' | awk '{print $2}' | sed 's/://') +# If charged +if [[ $(acpi | grep 'Discharging' | wc -c) -eq $(acpi | grep 'Charging' | wc -c) ]]; then + echo "BAT charged" + exit +fi + +# If charging +if [[ "$(acpi | grep 'Charging' | wc -c)" -gt 0 ]]; then + chg_id=$(acpi | grep 'Charging' | awk '{print $2'} | sed 's/://') + chg_prct=$(acpi | grep 'Charging' | awk '{print $4'} | sed 's/,//') + + echo "BAT$chg_id $chg_prct +" + exit +fi + +# If discharging echo "BAT$batid $prct -"