blob: d97fcb5390db53281cf20bf615af66d54bbfaee1 (
plain) (
blame)
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
27
28
29
30
31
32
|
#!/bin/bash
set -e
device="/sys/class/power_supply/BAT${BLOCK_INSTANCE:-0}"
status=$(cat "$device/status")
percent=$(cat "$device/capacity")
energy=$(cat "$device/energy_now")
status_text=""
if [[ $status = "Discharging" ]]; then
status_text=""
elif [[ $status = "Charging" ]]; then
status_text=" "
fi
printf '%i%% (%0.1fWh)%s\n' \
"$(( percent ))" \
"$(( energy ))e-6" \
"$status_text"
echo "${percent}%${status_text}"
# consider color and urgent flag only on discharge
if [[ $status = "Discharging" ]]; then
if [[ $percent -le 15 ]]; then
echo "#FF0000";
fi
if [[ $percent -le 5 ]]; then
exit 33
fi
fi
exit 0
|