blob: 2556a709dd16e81eef7a13299724f8b92b9df312 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
|