From 27fdcac5427a43a9e7bc40c8b1ce750106129d59 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Tue, 23 Nov 2021 14:56:16 +0100 Subject: [PATCH] [StumpWM] Better mode-line formatting handling --- org/config/stumpwm.org | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/org/config/stumpwm.org b/org/config/stumpwm.org index 5aed0f7..36728fd 100644 --- a/org/config/stumpwm.org +++ b/org/config/stumpwm.org @@ -494,6 +494,15 @@ the font I am using (see §[[#Theme-Fonts-28pc8141v5j0]]). : (("%g") ("%W") ("^>") ("mu-unread" . t) ("%m") ("%I") ("%l") ("%C") ("%M") ("%B") ("%d")) #+begin_src lisp :noweb yes +(defvar *mode-line-formatter-list* + '<> + "List of formatters for the modeline.") +#+end_src + +As you can see, ~generate-modeline~ generates the string defining +~*screen-mode-line-format*~ from the list of formatters we gave it with +the table [[modeline-format]]. +#+begin_src lisp (defun generate-modeline (elements &optional not-invertedp) "Generate a modeline for StumpWM. ELEMENTS should be a list of `cons'es which `car' is the modeline @@ -517,20 +526,21 @@ when the `car' is a formatter and t when it is a shell command." `(:eval (run-shell-command ,formatter t)) (format nil "~A" formatter)) (generate-modeline (cdr elements) (not not-invertedp))))))) +#+end_src +It is then easy to define a command that can call this function and +set this variable so we can sort of reload the mode-line. +#+begin_src lisp (defcommand reload-modeline () () "Reload modeline." (setf *screen-mode-line-format* - (cdr (generate-modeline '<>)))) - -(reload-modeline) + (cdr (generate-modeline *mode-line-formatter-list*)))) #+end_src -This variable as you can see is a list of elements, although here I am -only using one string. But it is absolutely possible to insert some -CLisp code in here that returns some string if the user needs some -code to return data that cannot be easily accesible otherwise. I might -add some at some point, but not today yet. +And actually, let’s reload the modeline immediately. +#+begin_src lisp +(reload-modeline) +#+end_src ** TODO Investigate why ~stumptray~ acts up :noexport: :PROPERTIES: