#!/bin/ksh set -x # config stuff BGCOLOR="#0c110e" FGCOLOR="#d6f5e4" BARHEIGHT=14 FONTS="-f tamzen:pixelsize=13" # probably won't need to mess with this BARPIPE="/tmp/bar.pipe" debug () { echo "$@" > /dev/stderr } cleanup () { echo "exiting" trap '' TERM kill 0 rm "$BARPIPE" exit 0 } clock () { while :; do date +"clock %Y.%m.%d %H:%M" sleep 5 done } bar () { typeset active_desk="$(bspc query -D --names -d)" typeset active_win="$(bspc query -N -n focused)" typeset current_time="" typeset output="" # set -x while read line; do output="%{l}" # handle incoming info case $line in desktop_focus*) active_desk="$(echo $line | cut -d" " -f3)" active_desk="$(bspc query -D --names -d $active_desk)" ;; clock*) current_time="$(echo $line | sed 's/clock //')" ;; esac # build workspace indicator bspc query -D --names |& while read -p desk; do if [ $desk = $active_desk ]; then # output="$output %{+u}$desk%{-u}" output="$output %{F#509a1c}$desk%{F-}" else output="$output $desk" fi done output="$output%{r}$current_time " printf '%s\n' "$output" done } if [ -e "$BARPIPE" ]; then echo "bar is already running" exit 1 fi # initialize stuff mkfifo -m 600 "$BARPIPE" trap cleanup INT TERM HUP QUIT EXIT # make the script nicer to other processes renice 15 $$ bspc subscribe all > "$BARPIPE" & clock > "$BARPIPE" & #bar < "$BARPIPE" | tee /dev/stderr | lemonbar -u 2 -g x$BARHEIGHT -B $BGCOLOR -F $FGCOLOR $FONTS bar < "$BARPIPE" | lemonbar -u 2 -g x$BARHEIGHT -B $BGCOLOR -F $FGCOLOR $FONTS