Advertisement
nnoell

topstatusbar.sh v3

Sep 24th, 2011
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.51 KB | None | 0 0
  1. #!/bin/bash
  2. # Depends: dzen2-xft-xpm-xinerama-svn && conky
  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_L=870
  9. WIDTH_R=410 #WIDTH_L + WIDTH_R = 1280
  10. HEIGHT=16
  11. X_POS_L=0
  12. X_POS_R=$WIDTH_L
  13. Y_POS=0
  14.  
  15. #Colors and font
  16. CRIT="#99cc66"
  17. BAR_FG="#3475aa"
  18. BAR_BG="#363636"
  19. DZEN_FG="#9d9d9d"
  20. DZEN_FG2="#444444"
  21. DZEN_BG="#020202"
  22. COLOR_SEP=$DZEN_FG2
  23. FONT="-*-montecarlo-medium-r-normal-*-11-*-*-*-*-*-*-*"
  24.  
  25. #Conky
  26. CONKYFILE="${HOME}/.config/conky/conkyrc"
  27. IFS='|'
  28. INTERVAL=1
  29. CPUTemp=0
  30. GPUTemp=0
  31. CPULoad0=0
  32. CPULoad1=0
  33. MpdInfo=0
  34. MpdRandom="Off"
  35. MpdRepeat="Off"
  36.  
  37. printVolInfo() {
  38.     Perc=$(amixer get Master | grep "Mono:" | awk '{print $4}' | tr -d '[]%')
  39.     Mute=$(amixer get Master | grep "Mono:" | awk '{print $6}')
  40.     echo -n "^fg($DZEN_FG2) VOL "
  41.     if [[ $Mute == "[off]" ]]; then
  42.         echo -n "$(echo $Perc | gdbar -fg $CRIT -bg $BAR_BG -h $BAR_H -w $BIGBAR_W -s o -ss 1 -sw 2 -nonl) "
  43.         echo -n "^fg()off"
  44.     else
  45.         echo -n "$(echo $Perc | gdbar -fg $BAR_FG -bg $BAR_BG -h $BAR_H -w $BIGBAR_W -s o -ss 1 -sw 2 -nonl) "
  46.         echo -n "^fg()${Perc}%"
  47.     fi
  48.     return
  49. }
  50.  
  51. #printVolInfo() {
  52. #   Perc=$(expr 4 \* $(ossmix vmix0-outvol | awk '{print $10}' | sed -e 's/.0//g')
  53.  
  54. #}
  55.  
  56. printVolInfo() {
  57.     Perc=$(amixer get Master | grep "Mono:" | awk '{print $4}' | tr -d '[]%')
  58.     Mute=$(amixer get Master | grep "Mono:" | awk '{print $6}')
  59.     echo -n "^fg($DZEN_FG2) VOL "
  60.     if [[ $Mute == "[off]" ]]; then
  61.         echo -n "$(echo $Perc | gdbar -fg $CRIT -bg $BAR_BG -h $BAR_H -w $BIGBAR_W -s o -ss 1 -sw 2 -nonl) "
  62.         echo -n "^fg()off"
  63.     else
  64.         echo -n "$(echo $Perc | gdbar -fg $BAR_FG -bg $BAR_BG -h $BAR_H -w $BIGBAR_W -s o -ss 1 -sw 2 -nonl) "
  65.         echo -n "^fg()${Perc}%"
  66.     fi
  67.     return
  68. }
  69.  
  70. printCPUInfo() {
  71.     [[ $CPULoad0 -gt 70 ]] && CPULoad0="^fg($CRIT)$CPULoad0^fg()"
  72.     [[ $CPULoad1 -gt 70 ]] && CPULoad1="^fg($CRIT)$CPULoad1^fg()"
  73.     echo -n " ^fg($DZEN_FG2)CPU ^fg($BAR_FG)${CPULoad0}%^fg($DZEN_FG2)/^fg($BAR_FG)${CPULoad1}%"
  74.     return
  75. }
  76.  
  77. printTempInfo() {
  78.     CPUTemp=$(acpi --thermal | awk '{print substr($4,0,2)}')
  79.     GPUTemp=$(nvidia-settings -q gpucoretemp | grep 'Attribute' | awk '{print $4}' | tr -d '.')
  80.     [[ $CPUTemp -gt 70 ]] && CPUTemp="^fg($CRIT)$CPUTemp^fg()"
  81.     [[ $GPUTemp -gt 70 ]] && GPUTemp="^fg($CRIT)$GPUTemp^fg()"
  82.     echo -n "^fg($DZEN_FG2)TEMP ^fg($BAR_FG)${CPUTemp}°^fg($DZEN_FG2)/^fg($BAR_FG)${GPUTemp}°"
  83.     return
  84. }
  85.  
  86. printMemInfo() {
  87.     [[ $MemPerc -gt 70 ]] && CPUTemp="^fg($CRIT)$MemPerc^fg()"
  88.     echo -n "^fg($DZEN_FG2)MEM ^fg($BAR_FG)${MemPerc}%"
  89.     return
  90. }
  91.  
  92. printDropBoxInfo() {
  93.     DropboxON=$(ps -A | grep -c dropbox)
  94.     if [[ $DropboxON == "0" ]]; then
  95.         echo -n "^fg($DZEN_FG2)DROPBOX ^fg()Off"
  96.     else
  97.         echo -n "^fg($DZEN_FG2)DROPBOX ^fg($CRIT)On"
  98.     fi
  99.     return
  100. }
  101.  
  102. printMpdInfo() {
  103.     MPDON=$(ps -A | grep -c mpd)
  104.     if [[ $MPDON == "0" ]]; then
  105.         echo -n "^fg($DZEN_FG2)MPD ^fg()Off"
  106.     else
  107. #       if [[ $MpdRepeat -eq "(null)" ]]; then
  108. #           echo -n "^fg($DZEN_FG2)MPD ^fg()Offline"
  109. #           [[ $(ncmpcpp --now-playing | wc -l) == 1 ]] && echo -n " ^fg($DZEN_FG2)| ^fg($BAR_FG)$(ncmpcpp --now-playing "%a") ^fg($DZEN_FG2)- ^fg($BAR_FG)$(ncmpcpp --now-playing "%t") ^fg($DZEN_FG2)| ^fg()$(ncmpcpp --now-playing "%l")"
  110. #       else
  111.             [[ $MpdRepeat == "On" ]] && MpdRepeat="^fg($CRIT)$MpdRepeat^fg()"
  112.             [[ $MpdRandom == "On" ]] && MpdRandom="^fg($CRIT)$MpdRandom^fg()"
  113.             echo -n "^fg($DZEN_FG2)REPEAT ^fg()$MpdRepeat ^fg($DZEN_FG2)| RANDOM ^fg()$MpdRandom ^fg($DZEN_FG2)| MPD $MpdInfo"
  114. #       fi
  115.     fi
  116.     return
  117. }
  118.  
  119. printDateInfo() {
  120.     echo -n "^fg()$(date '+%Y^fg(#444).^fg()%m^fg(#444).^fg()%d^fg(#3475aa)/^fg(#444444)%a ^fg(#363636)| ^fg()%H^fg(#444):^fg()%M^fg(#444):^fg()%S') "
  121.     return
  122. }
  123.  
  124. printSpace() {
  125.     echo -n " ^fg($COLOR_SEP)|^fg() "
  126.     return
  127. }
  128.  
  129. printLeft() {
  130.     while true; do
  131.         read CPULoad0 CPULoad1 CPUFreq MemUsed MemPerc MpdInfo MpdRandom MpdRepeat
  132.         printVolInfo
  133.         printSpace
  134.         printDropBoxInfo
  135.         printSpace
  136.         printMpdInfo
  137.         echo -n " ^fg()>^fg($BAR_FG)>^fg($DZEN_FG2)>"
  138.         echo
  139.     done
  140.     return
  141. }
  142.  
  143. printRight() {
  144.     while true; do
  145.         read CPULoad0 CPULoad1 CPUFreq MemUsed MemPerc MpdInfo MpdRandom MpdRepeat
  146.         printCPUInfo
  147.         printSpace
  148.         printMemInfo
  149.         printSpace
  150.         printTempInfo
  151.         printSpace
  152.         printDateInfo
  153.         echo
  154.     done
  155.     return
  156. }
  157.  
  158. #Print all and pipe into dzen
  159. conky -c $CONKYFILE -u $INTERVAL | printLeft | dzen2 -x $X_POS_L -y $Y_POS -w $WIDTH_L -h $HEIGHT -fn $FONT -ta 'l' -bg $DZEN_BG -fg $DZEN_FG -p -e '' &
  160. conky -c $CONKYFILE -u $INTERVAL | printRight | dzen2 -x $X_POS_R -y $Y_POS -w $WIDTH_R -h $HEIGHT -fn $FONT -ta 'r' -bg $DZEN_BG -fg $DZEN_FG -p -e ''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement