diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2019-02-05 13:51:30 +0100 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2019-02-05 13:51:30 +0100 |
commit | ce255302720ab5c53f0fcb04abbe2c4738ae251d (patch) | |
tree | b20d376bbfbed02820701f4526185c4ae3137473 /old/batwarn.sh |
Initial
Diffstat (limited to 'old/batwarn.sh')
-rwxr-xr-x | old/batwarn.sh | 26 |
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 |