Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- Nota=$(upower -i $(upower -e | grep BAT) | grep percentage)
- Estado=$(cut -d' ' -f2 <<<$(upower -i $(upower -e|grep BAT)|grep state) )
- Percent=$(cut -d' ' -f2 <<<$Nota)
- Icone='/usr/share/icons/hicolor/48x48/status'
- case $Percent in
- 100%) Faixa=100;cor=32
- ;;
- [0-9].*|1[0-9]*) Faixa=000;cor=31
- ;;
- [23][0-9]*) Faixa=020;cor=35
- ;;
- [45][0-9]*) Faixa=040;cor=33
- ;;
- [67][0-9]*) Faixa=060;cor=36
- ;;
- [89][0-9]*) Faixa=080;cor=32
- ;;
- esac
- case $Estado in
- fully-charged)Estado=-charged
- ;;
- discharging)unset Estado
- ;;
- charging)Estado=-charging
- ;;
- esac
- # Confere se o estado é fully-charged com carga menor que 100%,
- # se for muda o ícone para xfpm-primary-missing.png
- if [ "$Estado" = '-charged' -a "$Percent" != '100%' ]; then
- unset Faixa
- Estado=missing
- fi
- if [ "$DISPLAY" ]; then
- notify-send -i "$Icone"/xfpm-primary-$Faixa$Estado.png $Nota
- else
- echo -e "\e[$cor;7m$(echo $Nota) $(\
- [ -z "$Estado" ] && Estado=-discharging
- [ "$Estado" = 'missing' ] && Estado='-charged @ '$Percent
- echo $Estado)\e[m"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement