scripts

shell scripts
git clone git://git.bitsmanent.org/scripts
Log | Files | Refs | README

commit 5300bf8ceecff43628161506d43379e1dc415c19
parent 8446c1e64d390229bdfcba08d725cb1cfa4d5b54
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Sun, 24 Dec 2017 20:11:45 +0100

[dwmstatus] check battery values

Diffstat:
Msrc/dwmstatus | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/dwmstatus b/src/dwmstatus @@ -5,9 +5,12 @@ getbattery() { efull=$(cat /sys/class/power_supply/BAT0/energy_full) vnow=$(cat /sys/class/power_supply/BAT0/voltage_now) - r=$(echo "($enow * 100 / $vnow) * 100 / ($efull * 100 / $vnow)" |bc) + if [ $enow -eq 0 -o $vnow -eq 0 ]; then + r=? + else + r=$(echo "($enow * 100 / $vnow) * 100 / ($efull * 100 / $vnow)" |bc) + fi acplugged="$(cat $(du -a /sys/devices |grep 'AC0/online' |awk '{print $2}'))" - r="${r}%" [ $acplugged -eq 1 ] && r="${r}+" || r="${r}-" echo "$r"