How not to parse the modeline in stumpwm:
This is one of those where you look back on what you've written and cringe.
(defparameter *strip-newline* " | xargs echo -n"
"command to strip newline from shell commands")
(defparameter *mode-line-spacer* " | "
"string that seperates *mode-line-contents*")
(defparameter GRP-WIN-ML-FMT "%g %v^>"
"group & window mode-line format")
(defparameter DATE-COMMAND "date"
"date mode-line shell-command")
(defparameter POWER-COMMAND "acpi | awk '{print $4}'"
"power mode-line shell-command")
(defparameter MUSIC-COMMAND "mpc status | head -n 1"
"music mode-line shell-command")
(defparameter *mode-line-contents* (list GRP-WIN-ML-FMT DATE-COMMAND POWER-COMMAND MUSIC-COMMAND)
"list of mode-line variables and shell-commands")
(defmacro parse-mode-line (mode-text)
"macro for applying shell command wrapper to *mode-line-contents*. Strip newline with *strip-newline*"
`(eval (stumpwm:run-shell-command (concatenate 'string ,mode-text *strip-newline*) t)))
(setf stumpwm:*screen-mode-line-format*
`(:eval (mapcar #'(lambda (x) (concatenate 'string x *mode-line-spacer*))
(cons (car *mode-line-contents*)
(mapcar (lambda (x) (macroexpand-1 (parse-mode-line x)))
(cdr *mode-line-contents*))))))