Well, I am building some kind of configurable sidebar using FvwmButtons. It is a “bit”
heavy, I am well aware of that.
The idea is the following:
First, I have redefined all the submenús this way (I’ll just use a random submenu as example, same for the rest):
DestroyMenu menu_Terms
Test (EnvMatch menu_edit_mode 0) AddToMenu menu_Terms "Terminal" Title
Test (EnvMatch menu_edit_mode 1) AddToMenu menu_Terms "Anclar al panel" Title
Test (x urxvt) + "&urxvt%terminal.svg:$[icon_size]%" parse_menu "terminal" "urxvt"
Test (x rxvt) + "&rxvt%terminal.svg:$[icon_size]%" parse_menu "terminal" "rxvt"
Test (x mrxvt) + "&mrxvt%terminal.svg:$[icon_size]%" parse_menu "terminal" "mrxvt"
Test (x aterm) + "&aterm%terminal.svg:$[icon_size]%" parse_menu "terminal" "aterm"
Test (x xterm) + "&xtern%terminal.svg:$[icon_size]%" parse_menu "terminal" "xterm"
Test (x eterm) + "&eterm%terminal.svg:$[icon_size]%" parse_menu "terminal" "eterm"
At the top of the config, the variable menu_edit_mode is initialized to “0”. Those functions are the grain of salt here 
DestroyFunc MenuEditMode_wrapper
AddToFunc MenuEditMode_wrapper
+ I SetEnv menu_edit_mode 1
+ I Read $[FVWM_USERDIR]/menu.config
+ I Menu "$0" Mouse +40 +0m
+ I SetEnv menu_edit_mode 0
+ I Read $[FVWM_USERDIR]/menu.config
DestroyFunc parse_menu
AddToFunc parse_menu
+ I Test (EnvMatch menu_edit_mode 1) change_button "$0" "$1"
+ I Test (EnvMatch menu_edit_mode 0) Exec exec bash -c "$1"
DestroyFunc change_button
AddToFunc change_button
+ I Piperead 'rm -f $[FVWM_USERDIR]/sidepanel_info/"$0"'
+ I Piperead 'echo "$1" > $[FVWM_USERDIR]/sidepanel_info/"$0"'
+ I SetEnv media "$1"
+ I Read $[FVWM_USERDIR]/side_menu.config
parse_menu is basically a wrapper, that acts depending upon the value of menu_edit_mode. I know that those are not optimal.
MenuEditMode_wrapper reads the menu.config file two times, in that file live all the menus, and that is needed to set the title of the menu depending on wether we are in edit mode or not, so the user can know if the next click is going to launch a menu or to put that application into the button that we are editing. The first argument in the menu definition -“terminal” in this case- is the name of the variable that we are modifying, that holds the command of the button that we are editing. The rest of the stuff is to save the thing into a file and then read it, so the settings are saved between sessions.
In FvwmButtons the thing works thigs way:
*FvwmSidebar: (1x1, Font $[ThemeHeadFont], Padding $[small_margin] 0, Title (Left) Terminal, \
Action (Mouse 1) `Menu menu_Terms Mouse +40 +0m`, \
Action (Mouse 2) `FvwmConsole -terminal $[terminal]`, \
Action (Mouse 3) `MenuEditMode_wrapper "menu_Terms"`)
*FvwmSidebar: (1x1, Icon terminal.svg]*0.5+0-6, ActiveIcon terminal.svg]*0.6+0-6, PressIcon terminal.svg]*0.6+2-4, \
Title (side) "$[terminal_title]", \
Action (Mouse 1) `Exec exec $[terminal]`, \
Action (Mouse 3) `MenuEditMode_wrapper "menu_Terms"`)
Which, basically outputs this
If you left click into the “Terminal” title, you get a menu with the available terms, a normal menu which will launch the clicked program.
If you right click it, you edit the entry below. The panel reloads and the default terminal program changes. If you left click the icon, the terminal is launched directly. A right click on the icon produces the same effect than a right click on the Terminal word.
The stuff in the posts above is the way to initialize the variable if no file is found (which basically means that the user did not configure the panel him/herself). It is a list of programs that the panel will search for if the user did not configure the panel.
In case you are curious about the crappy mess I organized, the whole config at its current state is here:
jesgue.homelinux.org/public/6thp … wm.tar.bz2
I considered packing this all under a function as you say, because of the Break statement, which is too convenient in this case. This is a task for another day and should not be a hard thing to do. I will also abreviatte the test statements as you suggested.
Thanks for taking the time to answer. The help is much appreciated.
PS- In case you want to dive into my config, the files related to this thing are menu.config, side_menu.config and functions.config. The menu_edit_mode var is into config. I have already implemented all the changes you suggested. Still to test them, but the functionality of the menu is intact after the changes. So, it is the blanked out setup which I need to test to see if the apps are found ok with all those Test clauses.