aboutsummaryrefslogtreecommitdiff
path: root/home/.config/i3/status/battery
blob: 03bc7407271f16af4f8c20c3cee4c537373d300e (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
#!/bin/bash
set -e

device="/sys/class/power_supply/BAT${BLOCK_INSTANCE:-0}"
status=$(cat "$device/status")
percent=$(cat "$device/capacity")

status_text=""
if [[ $status = "Discharging" ]]; then
    status_text=" (DIS)"
elif [[ $status = "Charging" ]]; then
    status_text=" (CHR)"
fi

echo "${percent}%${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