Guest User

Untitled

a guest
Oct 10th, 2013
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. #! /bin/sh
  2. #
  3. # Example panel for dzen2
  4.  
  5. font_family='roboto'
  6. font_size=11
  7.  
  8. . panel_colors
  9.  
  10. adaptive_centering=0
  11. screen_width=$(sres -W)
  12. NORMIFS=$IFS
  13. FIELDIFS=':'
  14. PADDING=' '
  15.  
  16. while getopts 'af:s:' opt ; do
  17. case "$opt" in
  18. a)
  19. adaptive_centering=1
  20. ;;
  21. f)
  22. font_family=$OPTARG
  23. ;;
  24. s)
  25. font_size=$OPTARG
  26. ;;
  27. esac
  28. done
  29.  
  30. shift $((OPTIND - 1))
  31.  
  32. while read -r line ; do
  33. case $line in
  34. S*)
  35. # clock output
  36. sys_infos="^fg($COLOR_STATUS_FG)^bg($COLOR_STATUS_BG)${PADDING}${line#?}${PADDING}^fg()^bg()${PADDING}"
  37. ;;
  38. T*)
  39. # xtitle output
  40. title="^fg($COLOR_TITLE_FG)^bg($COLOR_TITLE_BG)${PADDING}${line#?}${PADDING}^fg()^bg()"
  41. ;;
  42. W*)
  43. # bspwm internal state
  44. wm_infos="$PADDING"
  45. IFS=$FIELDIFS
  46. set -- ${line#?}
  47. while [ $# -gt 0 ] ; do
  48. item=$1
  49. case $item in
  50. [OoFfUu]*)
  51. # desktops
  52. name=${item#?}
  53. case $item in
  54. O*)
  55. # focused occupied desktop
  56. FG=$COLOR_FOCUSED_OCCUPIED_FG
  57. BG=$COLOR_FOCUSED_OCCUPIED_BG
  58. ;;
  59. F*)
  60. # focused free desktop
  61. FG=$COLOR_FOCUSED_FREE_FG
  62. BG=$COLOR_FOCUSED_FREE_BG
  63. ;;
  64. U*)
  65. # focused urgent desktop
  66. FG=$COLOR_FOCUSED_URGENT_FG
  67. BG=$COLOR_FOCUSED_URGENT_BG
  68. ;;
  69. o*)
  70. # occupied desktop
  71. FG=$COLOR_OCUPPIED_FG
  72. BG=$COLOR_OCUPPIED_BG
  73. ;;
  74. f*)
  75. # free desktop
  76. FG=$COLOR_FREE_FG
  77. BG=$COLOR_FREE_BG
  78. ;;
  79. u*)
  80. # urgent desktop
  81. FG=$COLOR_URGENT_FG
  82. BG=$COLOR_URGENT_BG
  83. ;;
  84. esac
  85. wm_infos="${wm_infos}^fg(${FG})^bg(${BG})${PADDING}${name}${PADDING}"
  86. ;;
  87. L*)
  88. # layout
  89. layout=$(printf "%s" "${item#?}" | sed 's/^\(.\).*/\U\1/')
  90. wm_infos="${wm_infos}^fg()^bg()${PADDING}${PADDING}^fg($COLOR_LAYOUT_FG)^bg($COLOR_LAYOUT_BG)${PADDING}$layout${PADDING}"
  91. ;;
  92. esac
  93. shift
  94. done
  95. IFS=$NORMIFS
  96. ;;
  97. esac
  98. set -- $(printf '%s\0%s\0%s' "$wm_infos" "$title" "$sys_infos" | sed 's/\^[a-z]\+([^)]*)//g' | xargs -0 txtw -f "$font_family" -s "$font_size")
  99. left_width=$1
  100. center_width=$2
  101. right_width=$3
  102. left_indent=0
  103. right_indent=$((screen_width - right_width))
  104. available_center=$((screen_width - (left_width + right_width)))
  105. if [ $available_center -lt $center_width ] ; then
  106. center_indent=$((left_indent + left_width))
  107. else
  108. if [ $adaptive_centering -eq 1 ] ; then
  109. center_indent=$((left_width + (available_center - center_width) / 2))
  110. else
  111. center_indent=$(( (screen_width - center_width) / 2 ))
  112. fi
  113. fi
  114. printf "%s\n" "^pa($center_indent)$title^pa($left_indent)$wm_infos^pa($right_indent)$sys_infos"
  115. done
Advertisement
Add Comment
Please, Sign In to add comment