diff --git a/mowedline/.config/herbstluftwm/autostart.d/mowedline-tags.sh b/mowedline/.config/herbstluftwm/autostart.d/mowedline-tags.sh new file mode 100644 index 0000000..7a679bf --- /dev/null +++ b/mowedline/.config/herbstluftwm/autostart.d/mowedline-tags.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env zsh + +if ! whence hc; then + function hc() { herbstclient "$@"; } +fi + +# Keep my taglist widget up-to-date in mowedline. Quit if the "reload" +# hook is emitted because it will be restarted by this configuration. +while :; do + mowedline-client update taglist "$(hc tag_status)" 2>/dev/null + read -r event _ < <(hc --wait 'tag_changed|reload') + [[ "$event" == "reload" ]] && break +done & diff --git a/mowedline/.config/mowedline/init.org b/mowedline/.config/mowedline/init.org new file mode 100644 index 0000000..5e3d308 --- /dev/null +++ b/mowedline/.config/mowedline/init.org @@ -0,0 +1,84 @@ +Load the =matchable= module so I can use =match-lambda=. + +#+BEGIN_SRC scheme + (use matchable) +#+END_SRC + +Set the default font and color to something nicer. + +#+BEGIN_SRC scheme + (text-widget-font "Fantasque Sans Mono-13:bold") + (text-widget-color "#ededed") +#+END_SRC + +This formatter will parse the herbstluftwm tag status line, which +looks like this: + +#+BEGIN_EXAMPLE + #1 -2 :3 :4 :5 .6 .7 .8 .9 +#+END_EXAMPLE + +And turn it into something more useful. The symbols before the tag +names (numbers) have the following meaning: + +- =#= :: This tag is currently active. +- =-= :: This tag is visible on another monitor. +- =:= :: This tag isn't displayed, but has windows on it. +- =.= :: This tag isn't displayed and is empty. +- =!= :: This tag has an urgent window on it. + +First the tag line has to be split into separate parts. Each tag +status/name pair is split by a tab character and each status is only +one character. So I split the whole string on tabs and then make a +list out of each individual part, for easy access to the status +character. So we end up with something like: + +#+BEGIN_EXAMPLE + ((#\# #\1) (#\- #\2) (#\: #\3) ...) +#+END_EXAMPLE + +#+BEGIN_SRC scheme + (define (split-tag-list str) + (map string->list (string-split str "\t"))) +#+END_SRC + +Next we turn each part into something practical for display in +mowedline. + +#+BEGIN_SRC scheme + (define tag-display + (match-lambda + ((#\# . name-list) + (list '(color "#ececec" font "FontAwesome-10" "") + (string-append " " (list->string name-list) " "))) + ((#\- . _) '((color "#bfbfbf" font "FontAwesome-10" "") " ")) + ((#\. . _) '((color "#969696" font "FontAwesome-10" "") " ")) + ((#\: . _) '((color "#969696" font "FontAwesome-10" "") " ")) + ((#\! . _) '((color "#a85454" font "FontAwesome-10" "") " ")))) + + (define (tag-list-display tag-list) + (map tag-display tag-list)) +#+END_SRC + +Finally, bring it all together in a function that can be used as a +mowedline text formatter. + +#+BEGIN_SRC scheme + (define (tag-list-formatter text) + (tag-list-display (split-tag-list text))) +#+END_SRC + +Create a mowedline window, put it at the bottom. + +#+BEGIN_SRC scheme + (window #:position 'bottom + #:width 1843 + #:margin-bottom 15 + #:margin-left 46 + #:margin-right 15 + #:background 'transparent + + (widget:text #:name "taglist" #:format tag-list-formatter) + (widget:spacer #:flex 1) + (widget:clock)) +#+END_SRC diff --git a/mowedline/.gitignore b/mowedline/.gitignore new file mode 100644 index 0000000..c33d062 --- /dev/null +++ b/mowedline/.gitignore @@ -0,0 +1 @@ +init.scm diff --git a/mowedline/GNUmakefile b/mowedline/GNUmakefile new file mode 100644 index 0000000..e393a0b --- /dev/null +++ b/mowedline/GNUmakefile @@ -0,0 +1,6 @@ +include ../dotfiles.mk + +all: .config/mowedline/init.scm + +%.scm: %.org + $(call tangle,scheme)