diff options
| -rwxr-xr-x | battery | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -1,6 +1,6 @@ #!/bin/sh -names="sbs-20-000b BAT1" +names="sbs-20-000b BAT0" dir="" for n in $names; do @@ -16,23 +16,21 @@ if [ -z "$dir" ]; then fi fetch() { - cat /sys/class/power_supply/$dir/$1 + file="/sys/class/power_supply/$dir/$1" + [ -f "$file" ] && cat "$file" || exit 1 } status=$(fetch status) -if [ "$status" = "Full" ] ; then +if [ "$status" = "Full" ] || [ "$status" = "Unknown" ] ; 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)) minutes=$(($time/60-$hours*60)) - echo $status $(fetch capacity)%, "$hours"h "$minutes"m fi; |
