Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/sh
- #
- # BSPWM panel for lemonbar
- source ~/dotfiles/wm_config/wm_config
- num_mon=$(bspc query -M | wc -l)
- ## start reading lines from stdin
- while read -r line ; do
- case $line in
- S*)
- # clock output
- sys="${line#?} "
- ;;
- T*)
- # xtitle output
- title="%{F-} ${line#?} "
- ;;
- W*)
- # bspwm's state. Begin with some state variables
- wm="%{F$PANEL_ICON_COLOR} "
- curMonActive=true
- nodeState="%{F$PANEL_ICON_COLOR}%{F-} -"
- flagState=""
- IFS=':'
- set -- ${line#?}
- while [ $# -gt 0 ] ; do
- item=$1
- name=${item#?}
- case $item in
- [mM]*)
- [ $num_mon -lt 2 ] && shift && continue
- case $item in
- m*)
- # monitor
- FG=$PANEL_ICON_COLOR
- BG="-"
- curMonActive=false
- ;;
- M*)
- # focused monitor
- FG=$PANEL_HIGHLIGHT_COLOR
- BG="-"
- curMonActive=true
- ;;
- esac
- wm="${wm}%{F${FG}}%{B${BG}}%{A:bspc monitor -f ${name}:} ${name} %{A}%{B-}%{F-}"
- ;;
- [fFoOuU]*)
- case $item in
- f*)
- # free desktop
- FG=$PANEL_DIM_COLOR
- BG="-"
- label=""
- ;;
- F*)
- # focused free desktop
- FG=$PANEL_HIGHLIGHT_COLOR
- BG="-"
- label=""
- ;;
- o*)
- # occupied desktop
- FG=$PANEL_DIM_COLOR
- BG="-"
- label=""
- ;;
- O*)
- # focused occupied desktop
- FG=$PANEL_HIGHLIGHT_COLOR
- BG="-"
- label=""
- ;;
- u*)
- # urgent desktop
- FG=$PANEL_ICON_COLOR
- BG="-"
- label=""
- ;;
- U*)
- # focused urgent desktop
- FG=$PANEL_HIGHLIGHT_COLOR
- BG="-"
- label=""
- ;;
- esac
- wm="${wm}%{F${FG}}%{B${BG}}%{A:bspc desktop -f ${name}:}$label%{A}%{B-}%{F-}"
- ;;
- [LTG]*)
- # layout, state and flags
- #ignore for inactive monitors
- if [ "$curMonActive" = false ] ; then
- shift && continue
- fi
- case $item in
- L*)
- # Layout of monitor (Tiling, Max)
- monitorState="%{F$PANEL_HIGHLIGHT_COLOR}%{F-} ${name}"
- ;;
- T*)
- #State of focused node (Tiled, Pseudo, Fullscreen)
- nodeState="%{F$PANEL_ICON_COLOR}%{F-} ${name}"
- ;;
- G*)
- #Flags
- [[ -z $name ]] || flagState=" %{F$PANEL_HIGHLIGHT_COLOR}%{F-} ${name}"
- ;;
- esac
- ;;
- esac
- shift
- done
- #number of clients
- numnodes="%{F$PANEL_HIGHLIGHT_COLOR} %{F-}$(timeout 1 bspc query --nodes -n '.window.!sticky' --desktop focused | wc -l)"
- #[ $numnodes -gt 0 ] &&
- wm="${wm} $monitorState $nodeState$flagState $numnodes"
- ## redundantly update title also when wmchanges happen:
- title=$(xtitle)
- ;; ##end of WM part
- esac
- # print the three parts, starting with the center. If it gets to long, this way lemonbar will draw left and right over it.
- printf "%s\n" "%{c}${title}%{l}${wm} %{r} ${sys}"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement