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 -"