Hi,
I added the support of multiline strings à la Python, as a POC and only
with double-quotes.
It allow to embed more easily small shell scripts in f.exec or f.dynmenu
action param, without to quote every encountered ".
f.dynmenu """
cat <<EOF
"$(hostname)" f.title
"*$(date)" !"daemon xterm"
"Details..." f.dynmenu "/usr/local/bin/another_menu.sh"
"Shutdown" ("white":"red") !"shutdown -r now"
EOF
"""
What do you think of this?
https://github.com/maxatome/ctwm-mirror/commit/e04ca3c004f450d0eae2c92b9ac40598d1f3b717
++
Max.
Le 12/02/2023 à 23:34, Maxime Soulé a écrit :
Hi,
I just implemented a new f.dynmenu function.
The doc says:
f.dynmenu |string|
This function invokes a menu created dynamically by the execution
of the argument |string| passed to |/bin/sh|. On stdout of this
execution, the definition of one or several menu items is expected:
|"item1" [ ("fg1":"bg1") ] function1 "item2" [ ("fg2":"bg2") ]
function2 . . . "itemN" [ ("fgN":"bgN") ] functionN|
Example of use:
|f.dynmenu "/usr/local/bin/mymenu.sh"|
with |/usr/local/bin/mymenu.sh| defined as:
|#!/bin/sh cat <<EOF "$(hostname)" f.title "*$(date)" !"daemon
xterm" "Details..." f.dynmenu "/usr/local/bin/another_menu.sh"
"Shutdown" ("white":"red") !"shutdown -r now" EOF|
Note that the script is launched every times |f.dynmenu| is
invoked. The result is not cached. So if |mymenu.sh| content
changes at runtime, the resulting menu entries change at the next
|f.dynmenu| invocation.
It seems to work well, without any memory leak observed. Feel free to
test it: https://github.com/maxatome/ctwm-mirror/tree/dynmenu
Any remarks are welcome!
++
Max.