Przeglądaj źródła

~/.bin/warn-if-low.sh: Warn if low on battery (an not connected)

Use it in your crontab. I have it running every minute.
Lucas Stadler 14 lat temu
rodzic
commit
dcbc00fb68
1 zmienionych plików z 14 dodań i 0 usunięć
  1. 14 0
      .bin/warn-if-low.sh

+ 14 - 0
.bin/warn-if-low.sh

@ -0,0 +1,14 @@
1
#!/bin/bash
2
3
# Warn if the battery status is lower than 10%
4
5
charge_path="/sys/class/power_supply"
6
charge_full=`cat $charge_path/BAT0/charge_full`
7
charge_now=`cat $charge_path/BAT0/charge_now`
8
charge_rate=$(($charge_now * 100 / $charge_full ))
9
10
online=`cat $charge_path/AC0/online`
11
12
if [ "$online" = "0" -a $charge_rate -lt 10 ]; then
13
	DISPLAY=:0 zenity --error --text "Whoopey: You're low on energy (only $charge_rate% left)!"
14
fi