~jbauer/dotfiles

ref: daebf07b03e1fe9fe376eb75d5dd061c8fa047d3 dotfiles/.local/bin/batcheck -rwxr-xr-x 653 bytes
daebf07bJake Bauer Update README 11 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

if [ "$1" = "-p" ]; then
	echo $(apm -l) $(apm -a) > ~/.local/share/battery_percent
	exit
fi

while true; do
	perc=$(cat ~/.local/share/battery_percent | cut -d' ' -f1)
	ac=$(cat ~/.local/share/battery_percent | cut -d' ' -f2)
	if [ ! "$ac" -eq 1 ]; then
		if [ "$perc" -lt 10 ]; then
			notify-send -u critical "CRITICAL: Battery Drained" \
				"Hibernating soon!"
		elif [ "$perc" -lt 15 ]; then
			notify-send -u critical "WARNING: Battery Critically Low" \
				"Plug in a charger now or save all work and shut down."
		elif [ "$perc" -lt 20 ]; then
			notify-send "Warning: Battery Low" "Plug in a charger soon."
		fi
	fi
	sleep 300
done