dwmblocks/dwmblocks_scripts/dwm_battery

24 lines
575 B
Plaintext
Raw Permalink Normal View History

2022-12-12 15:59:27 +01:00
#!/bin/bash
2022-11-09 20:00:41 +01:00
2023-02-24 10:48:23 +01:00
prct=$(acpi | grep 'Discharging' | awk '{print $4}' | sed 's/,//')
batid=$(acpi | grep 'Discharging' | awk '{print $2}' | sed 's/://')
2022-11-09 20:00:41 +01:00
2023-02-24 12:00:57 +01:00
# 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
2023-02-24 10:48:23 +01:00
echo "BAT$batid $prct -"
2022-11-09 20:00:41 +01:00