diff options
| author | tslil clingman <> | 2019-02-02 22:07:02 -0500 |
|---|---|---|
| committer | tslil clingman <> | 2019-02-02 22:07:02 -0500 |
| commit | c89bde0eda904dd4b0fce455526c2a035dff2440 (patch) | |
| tree | 18802a51004750aeac0b0e6b3ff2c5944c7144b5 | |
| parent | 5ac945d092749e563826ae85226dd4b48407b406 (diff) | |
Error handling
| -rwxr-xr-x | battery | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -1,6 +1,6 @@ #!/bin/sh -names="sbs-20-000b BAT0 BAT1" +names="sbs-20-000b BAT1" dir="" for n in $names; do @@ -10,6 +10,11 @@ for n in $names; do fi; done +if [ -z "$dir" ]; then + echo \? + exit 0 +fi + fetch() { cat /sys/class/power_supply/$dir/$1 } @@ -19,11 +24,11 @@ status=$(fetch status) if [ "$status" = "Full" ] ; then echo $status else - + if [ "$status" = "Discharging" ]; then - time=$(fetch time_to_empty_avg) + time=$(fetch time_to_empty_avg) else - time=$(fetch time_to_full_avg) + time=$(fetch time_to_full_avg) fi; hours=$(($time/3600)) |
