Advertisement
atcasanova

Untitled

Jan 11th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.87 KB | None | 0 0
  1. #!/bin/bash
  2. batpath=/usr/share/icons/AwOkenWhite/clear/128x128/status
  3. acpi | grep -Eq "Charging|Full" && {
  4.         echo -n "Plugged ";
  5.         ext=-charging.png;
  6.         title="Charging" ;
  7.         Nota=$(acpi | grep -Eo "[0-9]{1,3}%");
  8.         echo $Nota
  9.     } || {
  10.         acpi | grep -Eo "[0-9]{1,3}%, ([0-9]{1,2}:){1,2}([0-9]{2}){0,1}" | sed 's/, / (/g;s/:[0-9][0-9]$/\ left)/g'
  11.         Nota=$(acpi | grep -Eo "[0-9]{1,3}%");
  12.         ext=.png
  13.         title="Discharging"
  14.     }
  15.  
  16. # Thanks to Julio Neves
  17. shopt -s extglob
  18. Faixa=$(case $Nota in
  19.     ?([01])[0-9]%) echo 000 ;;
  20.     [23][0-9]%) echo 020 ;;
  21.     [45][0-9]%) echo 040 ;;
  22.     [56][0-9]%) echo 060 ;;
  23.     [78][0-9]%) echo 080 ;;
  24.     *) echo 100;;
  25. esac) # Se seu bash for anterior ao 4.0, deve ser adicionado um abre parênteses antes de cada asterisco
  26.  
  27. notify-send -i $batpath/gpm-battery-$Faixa$ext $title $Nota # a opção -i especifica o ícone (/usr/share/icons)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement