You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
2.9KB

  1. #!/bin/bash
  2. COLOR_FOCUSED='#FF202020'
  3. COLOR_FREE='#FFCCCCCC'
  4. COLOR_OCCUPIED='#FF666666'
  5. num_mon=$(bspc query -M | wc -l)
  6. while read -r line ; do
  7. case $line in
  8. VS*)
  9. # volume state
  10. if [ ${line#??} == "on" ]
  11. then
  12. volume_state=`echo -e "%{T2}\uf028"`
  13. else
  14. volume_state=`echo -e "%{T2}\uf026"`
  15. fi
  16. ;;
  17. VI*)
  18. # volume output
  19. volume="%{T1}${line#??}"
  20. ;;
  21. BS*)
  22. # battery state
  23. if [ ${line#??} == "Charging" ]
  24. then
  25. batt_state=`echo -e "%{T2}\uf0e7"`
  26. elif [ ${line#??} == "Full" ]
  27. then
  28. batt_state=`echo -e "%{T2}\uf0e7"`
  29. else
  30. batt_state=""
  31. fi
  32. ;;
  33. BI*)
  34. # battery output
  35. charge="${line#??}"
  36. if [ $charge -lt "12" ]
  37. then
  38. batt=`echo -e "%{T2}\uf244"`
  39. elif [ $charge -lt "37" ]
  40. then
  41. batt=`echo -e "%{T2}\uf243"`
  42. elif [ $charge -lt "62" ]
  43. then
  44. batt=`echo -e "%{T2}\uf242"`
  45. elif [ $charge -lt "87" ]
  46. then
  47. batt=`echo -e "%{T2}\uf241"`
  48. else
  49. batt=`echo -e "%{T2}\uf240"`
  50. fi
  51. charge=`echo -e "%{T1}$charge"`
  52. ;;
  53. CD*)
  54. # date output
  55. clock_date=`echo -e "%{T2}\uf073 %{T1}${line#??}"`
  56. ;;
  57. CT*)
  58. # clock output
  59. clock=`echo -e "%{T2}\uf017 %{T1}${line#??}"`
  60. ;;
  61. T*)
  62. # xtitle output
  63. title="%{T1}${line#?}"
  64. ;;
  65. W*)
  66. # bspwm internal state
  67. wm_infos=""
  68. IFS=':'
  69. set -- ${line#?}
  70. while [ $# -gt 0 ] ; do
  71. item=$1
  72. name=${item#?}
  73. case $item in
  74. M*)
  75. # active monitor
  76. if [ $num_mon -gt 1 ] ; then
  77. wm_infos="$wm_infos %{F$COLOR_FOCUSED} ${name} %{F-}:"
  78. fi
  79. ;;
  80. m*)
  81. # inactive monitor
  82. if [ $num_mon -gt 1 ] ; then
  83. wm_infos="$wm_infos %{F$COLOR_OCCUPIED} ${name} %{F-}:"
  84. fi
  85. ;;
  86. O*)
  87. # focused occupied desktop
  88. wm_infos="${wm_infos}%{F$COLOR_FOCUSED}%{+u} ${name} %{-u}%{F-}"
  89. ;;
  90. F*)
  91. # focused free desktop
  92. wm_infos="${wm_infos}%{F$COLOR_FOCUSED}%{+u} ${name} %{-u}%{F-}"
  93. ;;
  94. U*)
  95. # focused urgent desktop
  96. wm_infos="${wm_infos}%{F$COLOR_FOCUSED}%{+u} ${name} %{-u}%{F-}"
  97. ;;
  98. o*)
  99. # occupied desktop
  100. wm_infos="${wm_infos}%{F$COLOR_OCCUPIED} ${name} %{F-}"
  101. ;;
  102. f*)
  103. # free desktop
  104. wm_infos="${wm_infos}%{F$COLOR_FREE} ${name} %{F-}"
  105. ;;
  106. h*)
  107. # urgent desktop
  108. wm_infos="${wm_infos} ${name} "
  109. ;;
  110. esac
  111. shift
  112. done
  113. ;;
  114. esac
  115. printf "%s\n" "%{l}${wm_infos}%{c}${title}%{r}${volume_state} ${volume} ${batt} ${charge}${batt_state} ${clock_date} ${clock} "
  116. done