summaryrefslogtreecommitdiff
path: root/battery
diff options
context:
space:
mode:
authortslil clingman <>2020-01-31 13:47:29 -0800
committertslil clingman <>2020-01-31 13:47:29 -0800
commitcef874a5aaf7a8c2ba60603176500099cf3c4362 (patch)
treee8bd1a3590e70f5427b6430034b2b65f2b697484 /battery
parent1e32cf0116d816dc64f744ed8812aa5a2a850f1e (diff)
Tweaks for bison
Diffstat (limited to 'battery')
-rwxr-xr-xbattery41
1 files changed, 7 insertions, 34 deletions
diff --git a/battery b/battery
index 4878dd1..29189ae 100755
--- a/battery
+++ b/battery
@@ -1,36 +1,9 @@
#!/bin/sh
-
-names="sbs-20-000b BAT0"
-dir=""
-
-for n in $names; do
- if [ -d "/sys/class/power_supply/$n" ] ; then
- dir=$n
- break
- fi;
-done
-
-if [ -z "$dir" ]; then
- echo \?
- exit 0
+report=$(acpi | tr -d ',')
+echo $report | grep -qv Unknown
+if [ "$?" = "0" ]; then
+ status=$(echo $report | cut -d\ -f 3 | cut -b 1)
+ perc=$(echo $report | cut -d\ -f 4)
+ time=$(echo $report | cut -d\ -f 5 | sed 's/\([0-9]*\):\([0-9]*\).*/\1h\2m/')
+ echo $status$perc $time
fi
-
-fetch() {
- file="/sys/class/power_supply/$dir/$1"
- [ -f "$file" ] && cat "$file" || exit 1
-}
-
-status=$(fetch status)
-
-if [ "$status" = "Full" ] || [ "$status" = "Unknown" ] ; then
- echo $status
-else
- if [ "$status" = "Discharging" ]; then
- time=$(fetch time_to_empty_avg)
- else
- time=$(fetch time_to_full_avg)
- fi;
- hours=$(($time/3600))
- minutes=$(($time/60-$hours*60))
- echo $status $(fetch capacity)%, "$hours"h "$minutes"m
-fi;