2020-07-18 12:00:48 +00:00
|
|
|
#!/bin/sh
|
2020-07-26 19:31:24 +00:00
|
|
|
|
|
|
|
read -r rate </sys/class/power_supply/BAT0/current_now
|
|
|
|
[ "$rate" = 0 ] && notify-send "Battery fully charged" && exit
|
|
|
|
|
|
|
|
read -r ac </sys/class/power_supply/AC/online
|
|
|
|
read -r charge_now </sys/class/power_supply/BAT0/charge_now
|
|
|
|
|
|
|
|
if [ "$ac" = 1 ] ; then
|
|
|
|
read -r charge_full </sys/class/power_supply/BAT0/charge_full
|
|
|
|
val=$(( charge_full-charge_now ))
|
|
|
|
else
|
|
|
|
val=$charge_now
|
|
|
|
fi
|
|
|
|
|
|
|
|
hr=$(( val / rate ))
|
|
|
|
mn=$(( (val * 60) / rate - hr * 60 ))
|
|
|
|
|
2020-10-30 16:55:41 +00:00
|
|
|
case $hr in
|
2020-07-26 19:31:24 +00:00
|
|
|
0)
|
2020-10-30 16:55:41 +00:00
|
|
|
case $mn in
|
2020-07-26 19:31:24 +00:00
|
|
|
0) notify-send "Battery fully charged" ;;
|
|
|
|
1) notify-send "1 minute remaining" ;;
|
|
|
|
*) notify-send "$mn minutes remaining" ;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
1)
|
2020-10-30 16:55:41 +00:00
|
|
|
case $mn in
|
2020-07-26 19:31:24 +00:00
|
|
|
0) notify-send "1 hour remaining" ;;
|
|
|
|
1) notify-send "1 hour, 1 minute remaining" ;;
|
|
|
|
*) notify-send "1 hour, $mn minutes remaining" ;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
*)
|
2020-10-30 16:55:41 +00:00
|
|
|
case $mn in
|
2020-07-26 19:31:24 +00:00
|
|
|
0) notify-send "$hr hours remaining" ;;
|
|
|
|
1) notify-send "$hr hours, 1 minute remaining" ;;
|
|
|
|
*) notify-send "$hr hours, $mn minutes remaining" ;;
|
|
|
|
esac
|
|
|
|
;;
|
2020-07-06 20:06:10 +00:00
|
|
|
esac
|