2016-01-12 15:02:12 -06:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
source "$DOTFILES_PATH/variables.bash"
|
2016-07-29 11:20:11 -05:00
|
|
|
source "$BAR_PATH/colors.bash"
|
2016-01-12 15:02:12 -06:00
|
|
|
|
2016-09-02 21:14:45 -05:00
|
|
|
PRIORITY=15000
|
2016-01-12 15:02:12 -06:00
|
|
|
|
2016-07-15 12:17:12 -05:00
|
|
|
PID_PREFIX="bspwm"
|
2016-01-12 15:02:12 -06:00
|
|
|
MATCH_PREFIX="W"
|
|
|
|
MATCH="$MATCH_PREFIX*"
|
|
|
|
|
2016-09-02 21:14:45 -05:00
|
|
|
DESKTOP_SPACER=" "
|
|
|
|
|
2016-11-12 14:18:20 -06:00
|
|
|
SWITCH_DESKTOP_COMMAND="switch_desktop"
|
|
|
|
|
2016-01-12 15:02:12 -06:00
|
|
|
ul="u"
|
|
|
|
if [ $BAR_UNDERLINE -eq 1 ]; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
ul="o"
|
|
|
|
fi
|
|
|
|
|
|
|
|
bar_module_bspwm() {
|
2016-09-02 21:14:45 -05:00
|
|
|
content="%{F$COLOR_FOREGROUND}"
|
2016-01-12 15:02:12 -06:00
|
|
|
line=$1
|
|
|
|
IFS=':'
|
|
|
|
set -- ${line#?}
|
|
|
|
while [ $# -gt 0 ] ; do
|
|
|
|
item=$1
|
|
|
|
name=${item#?}
|
|
|
|
cname="$name"
|
2016-11-12 14:18:20 -06:00
|
|
|
bname="%{A:$SWITCH_DESKTOP_COMMAND $cname:}${cname}%{A}"
|
2016-01-12 15:02:12 -06:00
|
|
|
case $item in
|
2016-01-12 15:03:13 -06:00
|
|
|
O*) # focused occupied desktop
|
2016-11-12 14:18:20 -06:00
|
|
|
content="${content}%{F$COLOR_HIGHLIGHT}%{U$COLOR_HIGHLIGHT}%{+${ul}}${bname}%{-${ul}}%{U-}%{F-}$DESKTOP_SPACER"
|
2016-01-12 15:02:12 -06:00
|
|
|
;;
|
2016-01-12 15:03:13 -06:00
|
|
|
F*) # focused free desktop
|
2016-11-12 14:18:20 -06:00
|
|
|
content="${content}%{F$COLOR_DARK}%{U$COLOR_DARK}%{+${ul}}${bname}%{-${ul}}%{U-}%{F-}$DESKTOP_SPACER"
|
2016-01-12 15:02:12 -06:00
|
|
|
;;
|
2016-01-12 15:03:13 -06:00
|
|
|
U*) # focused occupied desktop
|
2016-11-12 14:18:20 -06:00
|
|
|
content="${content}%{F$COLOR_URGENT}%{U$COLOR_URGENT}%{+${ul}}${bname}%{-${ul}}%{U-}%{F-}$DESKTOP_SPACER"
|
2016-01-12 15:02:12 -06:00
|
|
|
;;
|
2016-01-12 15:03:13 -06:00
|
|
|
o*) # occupied desktop
|
2016-11-12 14:18:20 -06:00
|
|
|
content="${content}%{F$COLOR_FOREGROUND}${bname}%{F-}$DESKTOP_SPACER"
|
2016-01-12 15:02:12 -06:00
|
|
|
;;
|
2016-01-12 15:03:13 -06:00
|
|
|
f*) # free desktop
|
2016-11-12 14:18:20 -06:00
|
|
|
content="${content}%{F$COLOR_DARK}${bname}%{F-}$DESKTOP_SPACER"
|
2016-01-12 15:02:12 -06:00
|
|
|
;;
|
2016-01-12 15:03:13 -06:00
|
|
|
u*) # urgent desktop
|
2016-11-12 14:18:20 -06:00
|
|
|
content="${content}%{F$COLOR_URGENT}${bname}%{F-}$DESKTOP_SPACER"
|
2016-01-12 15:02:12 -06:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2016-01-12 15:03:13 -06:00
|
|
|
echo -e "$content"
|
2016-01-12 15:02:12 -06:00
|
|
|
}
|
|
|
|
export -f bar_module_bspwm
|
|
|
|
|
2016-07-27 08:57:56 -05:00
|
|
|
bar_module_bspwm_updater()
|
|
|
|
{
|
|
|
|
bspc subscribe all > "$BAR_FIFO"
|
|
|
|
}
|
|
|
|
export -f bar_module_bspwm_updater
|
|
|
|
|
|
|
|
register_bar_module "$PRIORITY" "$MATCH" "bar_module_bspwm" "bar_module_bspwm_updater"
|
2016-01-12 15:02:12 -06:00
|
|
|
|