summaryrefslogtreecommitdiff
path: root/old/batwarn.sh
diff options
context:
space:
mode:
Diffstat (limited to 'old/batwarn.sh')
-rwxr-xr-xold/batwarn.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/old/batwarn.sh b/old/batwarn.sh
new file mode 100755
index 0000000..2556a70
--- /dev/null
+++ b/old/batwarn.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+function get_props_key() {
+ local v="$(grep "$1" <<<"$props")"
+ echo "${v/*=}"
+}
+
+function do_check() {
+ while read line; do
+ key="${line/=*}"
+ value="${line/*=}"
+ [[ $key = "POWER_SUPPLY_STATUS" ]] && status="$value"
+ [[ $key = "POWER_SUPPLY_CHARGE_NOW" ]] && charge="$value"
+ [[ $key = "POWER_SUPPLY_CHARGE_FULL_DESIGN" ]] && full="$value"
+ done </sys/class/power_supply/BAT1/uevent
+
+ percent="$(( charge * 100 / full ))"
+
+ if [[ $status = "Discharging" && $percent -le 30 ]]; then
+ i3-nagbar -m "Battery is at $percent%!"
+ fi
+}
+
+while true; do
+ do_check
+ sleep 30
+done