summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Schlosser <christoph@linux.com>2025-09-07 18:57:11 +0000
committerChristoph Schlosser <christoph@linux.com>2025-09-07 19:45:50 +0000
commit430418d198a055599031fe2693975c608d461260 (patch)
treef227327c2e63c0a9d1d562cdee6af2c477d32dfd
parent1c5c1b7d879d9888d617854d0cadd9a915ce3199 (diff)
downloaddots-430418d198a055599031fe2693975c608d461260.tar.gz
polybar: Add linux battery script
-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