nnoell

bottomstatusbar.sh v3

Sep 24th, 2011
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.22 KB | None | 0 0
  1. #!/bin/bash
  2. # Depends: dzen2-xft-xpm-xinerama-svn
  3. # Desc: dzen2 bar for XMonad, ran within xmonad.hs via spawnPipe
  4.  
  5. #Layout
  6. BAR_H=9
  7. BIGBAR_W=65
  8. WIDTH=390 #220 for trayer
  9. HEIGHT=16
  10. X_POS=890 #1060 for trayer and -w 939 in xmonad.hs
  11. Y_POS=784
  12.  
  13. #Colors and font
  14. FONT="-*-montecarlo-medium-r-normal-*-11-*-*-*-*-*-*-*"
  15. DZEN_BG="#020202"
  16. DZEN_FG="#9d9d9d"
  17. DZEN_FG2="#444444"
  18. CRIT="#99cc66"
  19. BAR_FG="#3475aa"
  20. BAR_BG="#363636"
  21. COLOR_SEP=$DZEN_FG2
  22.  
  23. #Options
  24. INTERVAL=5
  25. WIFISIGNAL=0
  26.  
  27. printDiskInfo() {
  28.     RFSP=$(df -h / | tail -1 | awk '{ print $5 }' | tr -d '%')
  29.     BFSP=$(df -h /boot | tail -1 | awk '{ print $5 }' | tr -d '%')
  30.     echo -n "^fg($DZEN_FG2) ROOT ^fg($BAR_FG)${RFSP}% "
  31.     echo -n "^fg($DZEN_FG2)BOOT ^fg($BAR_FG)${BFSP}%"
  32.     return
  33. }
  34.  
  35. printBattery() {
  36.     BatPresent=$(acpi -b | wc -l)
  37.     ACPresent=$(acpi -a | grep -c on-line)
  38.     if [[ $BatPresent == "0" ]]; then
  39.         echo -n "^fg($DZEN_FG2)AC ^fg($BAR_FG)on ^fg($DZEN_FG2)BAT ^fg($BAR_FG)off"
  40.         return
  41.     else
  42.         RPERC=$(acpi -b | awk '{print $4}' | tr -d "%,")
  43.         echo -n "^fg($DZEN_FG2)BAT "
  44.         if [[ $ACPresent == "1" ]]; then
  45.             echo -n "$(echo $RPERC | gdbar -fg $BAR_FG -bg $BAR_BG -h $BAR_H -w $BIGBAR_W -s o -ss 1 -sw 2 -nonl)"
  46.         else
  47.             echo -n "$(echo $RPERC | gdbar -fg $CRIT -bg $BAR_BG -h $BAR_H -w $BIGBAR_W -s o -ss 1 -sw 2 -nonl)"
  48.         fi
  49.         echo -n " ^fg()$RPERC%"
  50.     fi
  51.     return
  52. }
  53.  
  54. printWifiInfo() {
  55.     WIFIDOWN=$(wicd-cli --wireless -d | wc -l)
  56.     WIFISIGNAL=0
  57. #   [[ $WIFIDOWN -ne "1" ]] && WIFISIGNAL=$(wicd-cli --wireless -d | grep Quality | awk '{print $2}')
  58.     echo -n "^fg($DZEN_FG2)WIFI "
  59.     if [[ $WIFIDOWN -ne "1" ]]; then
  60.         WIFISIGNAL=$(wicd-cli --wireless -d | grep Quality | awk '{print $2}')
  61.         echo -n "$(echo $WIFISIGNAL | gdbar -fg $BAR_FG -bg $BAR_BG -h $BAR_H -w $BIGBAR_W -s o -ss 1 -sw 2 -nonl) "
  62.         echo -n "^fg()$WIFISIGNAL% "
  63.     else
  64.         echo -n "^fg($CRIT)N/A "
  65.     fi
  66.     return
  67. }
  68.  
  69. printSpace() {
  70.     echo -n " ^fg($COLOR_SEP)|^fg() "
  71.     return
  72. }
  73.  
  74. printBottomBar() {
  75.     while true; do
  76.         printDiskInfo
  77.         printSpace
  78.         printBattery
  79.         printSpace
  80.         printWifiInfo
  81.         echo
  82.         sleep $INTERVAL
  83.     done
  84.     return
  85. }
  86.  
  87. #Print all and pipe into dzen2
  88. printBottomBar | dzen2 -x $X_POS -y $Y_POS -w $WIDTH -h $HEIGHT -fn $FONT -ta 'r' -bg $DZEN_BG -fg $DZEN_FG -p -e ''
Advertisement
Add Comment
Please, Sign In to add comment