Dynamic menus

Maxime SoulĂ© <[email protected]> Sun, 12 Feb 2023 23:34:10 +0100
Newsgroups gmane.comp.window-managers.ctwm
Message-ID <[email protected]>
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.