summaryrefslogtreecommitdiff
path: root/private_dot_config/i3blocks/i3_battery.sh
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2024-12-11 20:46:32 +0100
committerSanto Cariotti <santo@dcariotti.me>2024-12-11 20:47:59 +0100
commitf22f1723c01b56da14ae1de3491a78af1bc4c464 (patch)
tree030411c811d3474c4b322eca29d1bf8e96b7511f /private_dot_config/i3blocks/i3_battery.sh
parentd8713792f93473fe14e01d151529fb6ef139448f (diff)
Dot files with `chezmoi`
Diffstat (limited to 'private_dot_config/i3blocks/i3_battery.sh')
-rw-r--r--private_dot_config/i3blocks/i3_battery.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/private_dot_config/i3blocks/i3_battery.sh b/private_dot_config/i3blocks/i3_battery.sh
new file mode 100644
index 0000000..97ea493
--- /dev/null
+++ b/private_dot_config/i3blocks/i3_battery.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+BAT=$(acpi -b | grep -E -o '[0-9][0-9]?%')
+CHECK_CHARGING=$(acpi -b | grep -E -o 'Charging')
+
+# Full and short texts
+echo "Battery: $BAT"
+echo "BAT: $BAT"
+
+if [ "$CHECK_CHARGING" != "" ]; then
+ echo "#1abc9c"
+ exit 0
+fi
+# Set urgent flag below 5% or use orange below 20%
+[ ${BAT%?} -le 5 ] && exit 33
+[ ${BAT%?} -le 35 ] && echo "#d35400"
+
+exit 0