aboutsummaryrefslogtreecommitdiff
path: root/quickshell/scripts/battery-info.sh
diff options
context:
space:
mode:
Diffstat (limited to 'quickshell/scripts/battery-info.sh')
-rwxr-xr-xquickshell/scripts/battery-info.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/quickshell/scripts/battery-info.sh b/quickshell/scripts/battery-info.sh
new file mode 100755
index 0000000..414d168
--- /dev/null
+++ b/quickshell/scripts/battery-info.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+target=$(upower --enumerate | awk '/BAT/ { print; exit }')
+
+upower -i "$target" | awk -F: '
+/energy:/ && !e { e=$2 }
+/voltage:/ && !v { v=$2 }
+/capacity:/ && !c { c=$2 }
+END {
+ gsub(/^[ \t]+/, "", e)
+ gsub(/^[ \t]+/, "", v)
+ gsub(/^[ \t]+/, "", c)
+
+ print "energy:", e
+ print "voltage:", v
+ print "capacity:", c
+}'