Advertisement
addy-dclxvi

panel-flat

Mar 5th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.13 KB | None | 0 0
  1. #! /bin/sh
  2. # based on default example from bspwm github
  3.  
  4. PANEL_FIFO=/tmp/panel-fifo
  5. PANEL_HEIGHT=24
  6. PANEL_WM_NAME=bspwm_panel
  7. PANEL_FONT="-lucy-tewi-medium-r-normal-*-11-90-100-100-c-60-iso10646-1"
  8.  
  9. COLOR_DEFAULT_FG="#dee3e0"
  10. COLOR_DEFAULT_BG="#343c48"
  11. COLOR_MONITOR_FG="#dee3e0"
  12. COLOR_MONITOR_BG="#343c48"
  13. COLOR_FOCUSED_MONITOR_FG="#dee3e0"
  14. COLOR_FOCUSED_MONITOR_BG="#528588"
  15. COLOR_FREE_FG="#737171"
  16. COLOR_FREE_BG="#343c48"
  17. COLOR_FOCUSED_FREE_FG="#dee3e0"
  18. COLOR_FOCUSED_FREE_BG="#528588"
  19. COLOR_OCCUPIED_FG="#dee3e0"
  20. COLOR_OCCUPIED_BG="#343c48"
  21. COLOR_FOCUSED_OCCUPIED_FG="#dee3e0"
  22. COLOR_FOCUSED_OCCUPIED_BG="#528588"
  23. COLOR_URGENT_FG="#dee3e0"
  24. COLOR_URGENT_BG="#ba5e57"
  25. COLOR_FOCUSED_URGENT_FG="#b48ead"
  26. COLOR_FOCUSED_URGENT_BG="#ba5e57"
  27. COLOR_STATE_FG="#343c48"
  28. COLOR_STATE_BG="#343c48"
  29. COLOR_SYS_FG="#dee3e0"
  30. COLOR_SYS_BG="#ba5e57"
  31.  
  32. trap 'trap - TERM; kill 0' INT TERM QUIT EXIT
  33.  
  34. [ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
  35. mkfifo "$PANEL_FIFO"
  36.  
  37. clock() {
  38.     while true; do
  39.         date +"S%a %b %-d, %H:%M"
  40.         sleep 15
  41.     done
  42. }
  43.  
  44. clock > "$PANEL_FIFO" &
  45. xtitle -sf 'T%s\n' > "$PANEL_FIFO" &
  46. bspc subscribe report > "$PANEL_FIFO" &
  47. num_mon=$(bspc query -M | wc -l)
  48.  
  49. panel_bar() {
  50. while read -r line ; do
  51.     case $line in
  52.         S*)
  53.             # clock output
  54.             sys="%{F$COLOR_SYS_FG}%{B$COLOR_SYS_BG} ${line#?} %{B-}%{F-}"
  55.             ;;
  56.         T*)
  57.             # xtitle output
  58.             title="%{F$COLOR_TITLE_FG}%{B$COLOR_TITLE_BG} ${line#?} %{B-}%{F-}"
  59.             ;;
  60.         W*)
  61.             # bspwm's state
  62.             wm=
  63.             IFS=':'
  64.             set -- ${line#?}
  65.             while [ $# -gt 0 ] ; do
  66.                 item=$1
  67.                 name=${item#?}
  68.                 case $item in
  69.                     [mM]*)
  70.                         case $item in
  71.                             m*)
  72.                                 # monitor
  73.                                 FG=$COLOR_MONITOR_FG
  74.                                 BG=$COLOR_MONITOR_BG
  75.                                 on_focused_monitor=
  76.                                 ;;
  77.                             M*)
  78.                                 # focused monitor
  79.                                 FG=$COLOR_FOCUSED_MONITOR_FG
  80.                                 BG=$COLOR_FOCUSED_MONITOR_BG
  81.                                 on_focused_monitor=1
  82.                                 ;;
  83.                         esac
  84.                         [ $num_mon -lt 2 ] && shift && continue
  85.                         wm="${wm}%{F${FG}}%{B${BG}}%{A:bspc monitor -f ${name}:} ${name} %{A}%{B-}%{F-}"
  86.                         ;;
  87.                     [fFoOuU]*)
  88.                         case $item in
  89.                             f*)
  90.                                 # free desktop
  91.                                 FG=$COLOR_FREE_FG
  92.                                 BG=$COLOR_FREE_BG
  93.                                 UL=$BG
  94.                                 ;;
  95.                             F*)
  96.                                 if [ "$on_focused_monitor" ] ; then
  97.                                     # focused free desktop
  98.                                     FG=$COLOR_FOCUSED_FREE_FG
  99.                                     BG=$COLOR_FOCUSED_FREE_BG
  100.                                     UL=$BG
  101.                                 else
  102.                                     # active free desktop
  103.                                     FG=$COLOR_FREE_FG
  104.                                     BG=$COLOR_FREE_BG
  105.                                     UL=$COLOR_FOCUSED_FREE_BG
  106.                                 fi
  107.                                 ;;
  108.                             o*)
  109.                                 # occupied desktop
  110.                                 FG=$COLOR_OCCUPIED_FG
  111.                                 BG=$COLOR_OCCUPIED_BG
  112.                                 UL=$BG
  113.                                 ;;
  114.                             O*)
  115.                                 if [ "$on_focused_monitor" ] ; then
  116.                                     # focused occupied desktop
  117.                                     FG=$COLOR_FOCUSED_OCCUPIED_FG
  118.                                     BG=$COLOR_FOCUSED_OCCUPIED_BG
  119.                                     UL=$BG
  120.                                 else
  121.                                     # active occupied desktop
  122.                                     FG=$COLOR_OCCUPIED_FG
  123.                                     BG=$COLOR_OCCUPIED_BG
  124.                                     UL=$COLOR_FOCUSED_OCCUPIED_BG
  125.                                 fi
  126.                                 ;;
  127.                             u*)
  128.                                 # urgent desktop
  129.                                 FG=$COLOR_URGENT_FG
  130.                                 BG=$COLOR_URGENT_BG
  131.                                 UL=$BG
  132.                                 ;;
  133.                             U*)
  134.                                 if [ "$on_focused_monitor" ] ; then
  135.                                     # focused urgent desktop
  136.                                     FG=$COLOR_FOCUSED_URGENT_FG
  137.                                     BG=$COLOR_FOCUSED_URGENT_BG
  138.                                     UL=$BG
  139.                                 else
  140.                                     # active urgent desktop
  141.                                     FG=$COLOR_URGENT_FG
  142.                                     BG=$COLOR_URGENT_BG
  143.                                     UL=$COLOR_FOCUSED_URGENT_BG
  144.                                 fi
  145.                                 ;;
  146.                         esac
  147.                         wm="${wm}%{F${FG}}%{B${BG}}%{U${UL}}%{+u}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-}%{-u}"
  148.                         ;;
  149.                     [LTG]*)
  150.                         # layout, state and flags
  151.                         wm="${wm}%{F$COLOR_STATE_FG}%{B$COLOR_STATE_BG} ${name} %{B-}%{F-}"
  152.                         ;;
  153.                 esac
  154.                 shift
  155.             done
  156.             ;;
  157.     esac
  158.     printf "%s\n" "%{l}${wm}%{c}${title}%{r}${sys}"
  159. done
  160. }
  161.  
  162. panel_bar < "$PANEL_FIFO" | lemonbar -a 12 -u 2 -g 1066x$PANEL_HEIGHT+150+6 -f "$PANEL_FONT" -F "$COLOR_DEFAULT_FG" -B "$COLOR_DEFAULT_BG" -n "$PANEL_WM_NAME" | sh &
  163.  
  164. wid=$(xdo id -a "$PANEL_WM_NAME")
  165. xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" "$wid"
  166.  
  167. wait
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement