aboutsummaryrefslogtreecommitdiff
path: root/quickshell/scripts
diff options
context:
space:
mode:
authorAargh Rai <aargh.rai+git@gmail.com>2026-05-10 14:57:19 +0530
committerAargh Rai <aargh.rai+git@gmail.com>2026-05-10 14:57:19 +0530
commitce5908ed1c96ac3e8cf9e9aa471441a1d653ab3b (patch)
tree8d7202ffcabeafb700562ea122b500e26d7af68c /quickshell/scripts
parent8c1a8c052568c6f3fd9a76d01fc6bf694b85ff6e (diff)
switched from power-profiles-daemon to tlp & removed the option to manually change the power mode, tlp does it automatically now!
Diffstat (limited to 'quickshell/scripts')
-rw-r--r--quickshell/scripts/battery-info.py39
-rwxr-xr-xquickshell/scripts/battery-info.sh17
2 files changed, 56 insertions, 0 deletions
diff --git a/quickshell/scripts/battery-info.py b/quickshell/scripts/battery-info.py
new file mode 100644
index 0000000..c3958f7
--- /dev/null
+++ b/quickshell/scripts/battery-info.py
@@ -0,0 +1,39 @@
+# this script was used to generate the battery-info.sh via chatgpt
+
+import subprocess
+
+output = subprocess.run(
+ ["upower", "--enumerate"],
+ capture_output=True
+).stdout.decode('utf-8')
+
+target = None
+
+for line in output.split("\n"):
+ if "BAT" not in line:
+ continue
+ target = line
+ break
+
+print(line)
+
+output = subprocess.run(
+ ["upower", "-i", line],
+ capture_output=True
+).stdout.decode('utf-8')
+
+energy = None
+voltage = None
+capacity = None
+
+for line in output.split("\n"):
+ if energy is None and "energy:" in line:
+ energy = line.split(":")[1].strip()
+ if voltage is None and "voltage:" in line:
+ voltage = line.split(":")[1].strip()
+ if capacity is None and "capacity:" in line:
+ capacity = line.split(":")[1].strip()
+
+print("energy:", energy)
+print("voltage:", voltage)
+print("capacity:", capacity)
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
+}'