Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Autor: Daemonio (Marcos Paulo Ferreira)
- # Contato: undefinido gmail com
- #
- # [monitorar_bateria.sh]
- # Script que lanca uma notificacao quando
- # a bateria estiver sendo usada.
- # Isso eh util para os lerdos como eu que
- # esquecem de ligar o notebook na tomada. :|
- #
- # Mon Mar 28 09:30:39 BRT 2011
- # Sun May 1 13:12:08 BRT 2011
- #
- state_file='/proc/acpi/battery/BAT/state'
- info_file='/proc/acpi/battery/BAT/info'
- rate='0.9' # 90%
- while :
- do
- REMAINING=$(sed -n '/^remaining capacity:/s/[^0-9]//gp' $state_file)
- LAST_FULL=$(sed -n '/^last full capacity:/s/[^0-9]//gp' $info_file)
- RATE=$(echo "$LAST_FULL * $rate" | bc)
- if [ $REMAINING -lt ${RATE%.*} ] && grep -q 'discharging' $state_file
- then
- notify-send -u critical -t 5000 'A bateria esta sendo usada.'
- fi
- sleep 500
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement