Menus are useful tools and can be generated dynamically in FVWM. The FvwmExpose function on the last page is an example of that. One of the nice thing about FVWM menus is being able to create them from scripts. This is nice because you could create a menu based off the wallpapers in a directory (example already shown), or you could create a menu that list all the contents of the directory (and its subdirectories). Some places to look for more information about this is to check out the fvwm-menu-directory and fvwm-menu-headlines scripts that come with FVWM (complete with man pages). Also look up MissingSubmenuFunction, DynamicPopupAction and DynamicPopdownAction in the FVWM man page.
Debian is my distro of choice. One nice tool that comes with debian is the 'menu' package which is used to generate menus. The FVWM debian package comes with a script that takes advantage of this to generate a menu of the installed apps on your debian box. I have taken this script and modified to my own liking and use it to generate a DebianMenu on my desktop. If you have debian and are interested in this you'll need to grab the following three files: fvwm_menu, fvwm_menu.h and fvwm_menu_data.h. Then you'll have to put these files in your $[fvwm_scrpt] directory. After that you'll also need to add the following function to your fvwm2rc.
##### # DebianMenu ########### DestroyFunc BuildDebianMenu AddToFunc BuildDebianMenu + I Exec if [ -f "$[fvwm_home]/DebianMenu" ] then rm $[fvwm_home]/DebianMenu fi + I PipeRead 'update-menus --menumethod $[fvwm_scrpt]/fvwm_menu; \ cat $[fvwm_home]/DebianMenu' |
Though the use of the menu package this function creates a file called $HOME/.fvwm/DebianMenu. If you use another location as your $[fvwm_home] you'll have to modify the fvwm_menu script slightly. It then cats the file and uses it to create the DebianMenu. I have this set up so you have to run the function BuildDebianMenu anytime the menu needs to be updated, but the nice thing about it is all you have to do is 'Read $[fvwm_home]/DebianMenu' at startup to include this menu in your setup. To get to the menu, just add it to your FvwmRootMenu and 'Popup DebianMenu'.
For the next example, I have modified the script fvwm-menu-directory to use to create myself a MediaMenu to list my music. I suggest you first take a look at both the fvwm-menu-directory and fvwm-menu-headlines man page first. The following is an example for a modified version of fvwm-menu-directory. I have two main features I added to the script. The first one is for any directory it will look for a file called [directory_name].png and if it finds one it will use that image as the Icon for that directory in the menu (and in the title of the submenu generated by that directory), along with this feature I have set it up so you can ignore all .png files and not list them in the menu. The second feature I have added is the ability to only list parts of the directory, so the menu doesn't get too big. Before I explain how these work lets first look at the FuncFvwmMenuDirectory that is used to generate these functions and the 'MediaMenu' that spawns them.
DestroyFunc FuncFvwmMenuDirectory AddToFunc FuncFvwmMenuDirectory + I PipeRead '$[fvwm_scrpt]/fvwm-menu-directory --title "%d" --dir "$0" \ --links --command-file "exec xmms \\"%f\\"" \ --command-title "exec xmms \\"%d\\"" \ --icon-title "$0.png" --icon-file "menu/notes.png" \ --exclude ".png"' ##### # MediaMenu ########### DestroyMenu MusicMenu AddToMenu MusicMenu "Music" Title AddToMenu MusicMenu MissingSubmenuFunction FuncFvwmMenuDirectory + "Artists A-B%menu/music.xpm%" Popup /home/music/albums/artists|[14AB] + "Artists C-G%menu/music.xpm%" Popup /home/music/albums/artists|[CDEFG] + "Artists H-K%menu/music.xpm%" Popup /home/music/albums/artists|[HIJK] + "Artists L-O%menu/music.xpm%" Popup /home/music/albums/artists|[LMNO] + "Artists P-S%menu/music.xpm%" Popup /home/music/albums/artists|[PQRS] + "Artists T-Z%menu/music.xpm%" Popup /home/music/albums/artists|[TUVWXYZ] + "Unsorted%menu/music.xpm%" Popup /home/music/albums/unsorted + "Assorted Music%menu/music.xpm%" Popup /home/music/assorted + "Collections%menu/music.xpm%" Popup /home/music/albums/collections + "Soundtracks%menu/music.xpm%" Popup /home/music/albums/soundtracks |
How the MediaMenu works is it sets up FuncFvwmMenuDirectory as the MissingSubmenuFunction. What this does is if you try to Popup a submenu that doesn't exist, it will send the name of the submenu to the FuncFvwmMenuDirectory. That function then generates the submenu so it can be PopedUp. How my FuncFvwmMenuDirectory works is it takes a directory name followed by the list of the starting letters of the items to include. For example, 'Popup /home/music/albums/artists|[CDEFG]' will only list the files/directories in /home/music/albums/artists that start with C, D, E, F or G. Here is an example of what this will look like.
Advanced Functions | index | Advanced FvwmButtons |