summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpolybar/Linux-battery.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/polybar/Linux-battery.sh b/polybar/Linux-battery.sh
new file mode 100755
index 0000000..7527d21
--- /dev/null
+++ b/polybar/Linux-battery.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+while true; do
+ PERCENT=$(cat /sys/class/power_supply/BAT1/capacity)
+ MIN_REMAINING=$(acpi -r | cut -d',' -f3 | cut -d':' -f1,2)
+ CHARGING=''
+ if [[ "$(cat /sys/class/power_supply/BAT1/status)" == "Charging" ]]; then
+ CHARGING='+'
+ fi
+ echo -n "$PERCENT%"
+ if [[ ! -z $CHARGING || ! -z $MIN_REMAINING ]]; then
+ echo -n " (${CHARGING}${MIN_REMAINING/ /})"
+ fi
+ echo
+ sleep 60
+done