Advertisement
jrswab

i3blocks Battery Script

Aug 2nd, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.42 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. POW=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -o '[0-9]*%' -m 1)
  4. PO=${POW::-1}
  5.  
  6. case $PO in
  7.     [76-100]*)
  8.         tput setaf 2; echo $POW
  9.         tput sgr0
  10.         ;;
  11.     [50-75]*)
  12.         tput setaf 2; echo $POW
  13.         tput sgr0
  14.         ;;
  15.     [26-49]*)
  16.         tput setaf 3; echo $POW
  17.         tput sgr0
  18.         ;;
  19.     [11-25]*)
  20.         tput setaf 3; echo $POW
  21.         tput sgr0
  22.         ;;
  23.     [0-10]*)
  24.         tput setaf 1; echo $POW
  25.         tput sgr0
  26.         ;;
  27. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement