fvwm2-menu-desktop(1)

✨ fvwm2-menu-desktop β€” the Fvwm Modules glow-up ✨

okay bestie, sit down, hydrate, because we're reading fvwm2-menu-desktop(1) together and honestly? it's iconic. this is the page that turns your boring old XDG menu files into actual, functioning Fvwm menus. πŸ’…


πŸ’– NAME πŸ’–

fvwm2-menu-desktop β€” she reads XDG menu files and creates Fvwm menus. that's the whole job. that's the assignment. periodt.


πŸ¦‹ SYNOPSIS πŸ¦‹

fvwm2-menu-desktop [ --help|-h ] [ --version ] [ --install-prefix DIR ]
[ --desktop NAME ] [ --menu-type NAME ] [ --theme NAME ] [
--with-titles|-w ] [ --without-titles ] [ --enable-mini-icons ] [
--size|-s NUM ] [ --mini-icon-dir DIR ] [ --app-icon NAME ] [ --dir-icon
NAME ] [ --title|-t NAME ] [ --insert-in-menu NAME ] [ --get-menus
all|desktop ] [ --set-menus menu_paths ] [ --all-menus ] [
--include-items NAME ] [ --regen-cmd CMD ] [ --term-cmd CMD ] [
--dynamic ] [ --menu-error|-e ] [ --verbose|-v ]

look at all those flags. she has range. 🌈


🌸 DESCRIPTION 🌸

okay so real talk: this is a python script. what it does is parse XDG menu definitions and build corresponding fvwm menus out of them. no cap.

and the vibe check on dependencies? this script depends on python-xdg to run. that's the tea. πŸ«–


πŸ’… OPTIONS πŸ’…

πŸ‘‘ Main Options πŸ‘‘

  • --help β€” shows the help and then dips out. classic.
  • --version β€” shows the version and exits. very demure, very mindful.
  • --get-menus all|desktop β€” prints a space separated list of full menu paths found on the system. no menu generation happens here, we're just window shopping. πŸ›οΈ
    • all will print all menus found on the system except the empty ones.
    • desktop will print the menu(s) that would be generated by the script.
and like, to be clear: no menu generation is done. zero. none. it's just listing.
  • --desktop NAME β€” optional parameter that sets the NAME of the desktop XDG .menu file(s) to use. this one overrides any default menus set via FvwmForm-XDGMenu-Config, and it makes the script go find menus where NAME is part of the file name. possible names include: gnome, kde, xfce, lxde, debian, etc.

you can run this in conjunction with --menu-type to control which .menu file(s) get used. duo goals fr. 🫢

  • --menu-type NAME β€” optional parameter that sets the NAME of the XDG menu type to use. this also overrides any default menus set via FvwmForm-XDGMenu-Config and makes the script find menus where NAME is part of the file name. possible NAME types could be: applications, settings, preferences, etc.

when you use it with --desktop, only menus whose file name matches '*destkop*menutype*' are found. (yes, destkop. that's what the page says. we do not edit the sacred text. πŸ™ˆ) if no menus are found, the script exits with an error.

  • --all-menus β€” builds all menus found on the system. if you use it with --desktop or --menu-type, it'll build all the menus matching those settings instead. greedy in the best way.
  • --install-prefix DIR β€” optional parameter to override the standard locations for XDG menu definitions. it tells fvwm2-menu-desktop to look in DIR for .menu files instead of the standard locations /etc/xdg/menus (and $HOME/.config/menus if it exists).
  • --with-titles|-w β€” if this is set, menus are generated with titles. this is the default, bestie. it can also be used to override the FvwmForm-XDGMenu-Config default setting.
  • --without-titles β€” if this is set, menus are generated without titles. the default is to generate with titles, so this is you choosing chaos. respect. πŸ’€
  • --title|-t NAME β€” defines the menu title NAME of the top menu used by Fvwm's Menu or Popup commands. default is "XDGMenu".
  • --include-items NAME β€” controls whether the additional menu items 'Regenerate' and 'Configure' get included in the top level menu. NAME can be one of regenerate, config, both, or none. the default is both.
  • --regen-cmd CMD β€” sets the fvwm command CMD that runs when the menu item 'Regenerate' is selected. the default is "PipeRead fvwm2-menu-desktop".
  • --term-cmd CMD β€” sets the terminal emulator command CMD that's used to run terminal applications in. CMD needs to end with an execute option, like xterm's -e option, which will run the command that gets appended to CMD. the default is "xterm -e".
πŸ“ Debian specific: per Debian policy, the default is changed to "x-terminal-emulator -e".
  • --dynamic β€” this one is for creating dynamic menus using DynamicPopUpAction and DynamicPopDownAction. it adds a 'recreate' to the DestroyMenu command on the top level menu so those actions don't get Destroyed when the menu is regenerated. keeping the vibes alive. ✨
  • --insert-in-menu NAME β€” option to insert generated menu(s) IN a menu NAME (its top title). this makes it so the top level menu is not Destroyed and the items are added to the end.
😭 heads up bestie: menus regenerated with this option will append the menu items at the end of the existing menu. each time the menu is regenerated, new menu items appear, giving you a growing menu of duplicate items. you have to regenerate the whole menu via a function or restart fvwm. see EXAMPLES below for some solutions.
  • --set-menus menu_paths β€” generates all menus listed in a space separated list of full menu paths. this option overrides any defaults and the --desktop|--menu-type settings. she does not share the spotlight.
  • --menu-error |-t β€” if this option is present and python-xdg is not found, the script will print the error in the generated menu. used in the default-config. (note: the page literally writes it as --menu-error |-t with that space, so we're keeping it exactly like that. 🫑)
  • --verbose β€” enables additional information printouts on STDERR. she's yapping but it's useful yapping.

πŸŽ€ Icons Options πŸŽ€

by default, fvwm2-menu-desktop builds menus without mini-icons. to enable mini-icons, use the following options. πŸ¦‹

if ImageMagick is installed on the system, the script will resize and copy the icons to $FVWM_USERDIR/.icons. this can take awhile. you should be prepared to wait the first time you generate the icons. once the icons have been generated the script should run faster. if it is still to slow using icons, see EXAMPLES for ways to limit how often the menu is generated to speed things up. (and yes, it says "to slow" in the original. we love a typo moment. πŸ’œ)

  • --enable-mini-icons β€” enables mini-icons in the menus. if set, 24x24 mini-icons are used. if the specified icon isn't that size it will be converted if ImageMagick is installed and saved in $HOME/.fvwm/icons or to the directory specified with the --mini-icon-dir option. otherwise no icon appears in the menu for that entry. with most distributions, all the menu entries will have mini-icons appropriate to the application. slay.
  • --theme NAME β€” defines the used icon theme. default is gnome, but all others found in /usr/share/icons could be used β€” except the hicolor theme, because it's the default fallback theme if no icon is found. can't use the fallback as your main character, that's just how it is.
  • --size|-s NUM β€” if --enable-mini-icons is used, the size of the icons can be changed with this parameter. default is 24.
  • --mini-icon-dir DIR β€” when the right size mini-icon isn't available, fvwm2-menu-desktop creates icons with the right size in $HOME/.fvwm/icons. if you don't want to use the default directory, $HOME/.fvwm/icons, use this option to specify a different folder.
  • --app-icon NAME β€” sets the default application icon if no others are found. default is 'gnome-applications'.
  • --dir-icon NAME β€” sets the default directory icon if no others are found. default is 'gnome-fs-directory'.

🌈 USAGE 🌈

fvwm2-menu-desktop outputs XDG .menu files in the syntax of fvwm menus. when fvwm2-menu-desktop is run with no options, it will load defaults from the FvwmForm-XDGMenu-Config file (see below) and then search your system for suitable menu file(s). to see which menus are available on your system, run:

fvwm2-menu-desktop --get-menus all

if no menus are found you may not have any installed on your system. by default menus are stored as *.menu files in /etc/xdg/menus, $HOME/.config/menus or the location set in $XDG_MENU_PREFIX. you can use --install-prefix to specify another location search for menus.

though a combination of command line options and the FvwmForm-XDGMenu-Config settings, fvwm2-menu-desktop can generate any combination of the menus found. to get a list of what menu(s) would be generated, use the --get-menus desktop option. the following will list all menus generated if fvwm2-menu-desktop was run with no options:

fvwm2-menu-desktop --get-menus desktop

fvwm2-menu-desktop determines which menu(s) to generate as follows:

  • if no config file is found, all menus will be weighted and the script will generate the best (highest weight) menu found.
  • if a config file is found (and override options are not used) the script will generate all menus selected in FvwmForm-XDGMenu-Config.
  • --desktop, --menu-type, --set-menus and --all-menus will override any menus selected in FvwmForm-XDGMenu-Config.
  • --desktop and --menu-type will only include menus whose name matches '*desktop*menutype*'. if used with --all-menus, all matching menus are generated. if used without --all-menus, only the highest weighted menu is generated.
  • --set-menus generates menus from the list of full path menu file names.
  • --all-menus by itself will generate all menus found.

by default fvwm2-menu-desktop will generate a menu whose top level name is "XDGMenu". to tell fvwm to read the output of fvwm2-menu-desktop to create the menu XDGMenu, add the following to your fvwm config file:

PipeRead 'fvwm2-menu-desktop'
⚠️ Warning: depending on the options used this command may be slow and fvwm will pause until this command is complete. see EXAMPLES below for more details and possible workarounds.

once the menu is generated you can open the menu by using the command "Menu XDGMenu". you can also include this in the MenuFvwmRoot menu by:

AddToMenu MenuFvwmRoot "XDG Menu" Popup XDGMenu

fvwm2-menu-desktop can be configured though both command line options and a FvwmForm GUI to customize the menu(s) that get generated. iconic behavior honestly.


🧚 GUI 🧚

FvwmForm-XDGMenu-Config is a FvwmForm interface that can be used to configure the defaults for fvwm2-menu-desktop. you can access this from the "Configure" item in the top level menu that is generated, or run the following from within FvwmConsole:

Module FvwmPerl -l fvwm-menu-desktop-config.fpl

this form can be used to select which menu(s) get generated by default, along with setting many (but not all) of the available options. when you click "Save Settings", the form will write a config file located at $FVWM_USERDIR/.FvwmForm-XDGMenu-Config that fvwm2-menu-desktop will parse for defaults when run. ✨

see the help inside of FvwmForm-XDGMenu-Config for more information. πŸ’–

✨ EXAMPLES ✨

okay so there are so many ways to set things up when fvwm runs fvwm2-menu-desktop to generate the menu, and honestly pick whichever one vibes with you. one method is to just generate the menu when fvwm loads and then use the GUI config tool to change any options. for that you only need to add the following to the fvwm config file:

AddToMenu MenuFvwmRoot "XDG Menu" Popup XDGMenu
PipeRead 'fvwm2-menu-desktop'

The menu is created once when fvwm loads. since menu creation can sometimes be slow, this could cause fvwm to take longer to load than one wants. 😭

The menu is only generated when fvwm starts. so if software is installed or removed you will have to select the 'Regenerate' option to rebuild the menu. fr fr.

One way to speed things up is to save the menu in a file and only generate the menu when 'Regenerate' is selected. to do this use --regen-cmd to call a custom function and write the menu to a file using a command like

fvwm2-menu-desktop --regen-cmd XDGRegen > $FVWM_USERDIR/.XDGMenu

Then add the following to the fvwm config file to define the function XDGRegen. heads up bestie: the second to last line will generate the menu if the menu file doesn't exist when fvwm starts. πŸ‘‘

DestroyFunc XDGRegen
AddToFunc XDGRegen
+ I PipeRead 'fvwm2-menu-desktop --regen-cmd XDGRegen > \
    $[FVWM_USERDIR]/.XDGMenu; echo "Nop"'
+ I Read $[FVWM_USERDIR]/.XDGMenu

Test (!f $[FVWM_USERDIR]/.XDGMenu) XDGRegen
Read $[FVWM_USERDIR]/.XDGMenu

Besides creating a top level menu, fvwm2-menu-desktop can insert the menu into an existing menu using the --insert-in-menu option. for example one could create the menu MenuFvwmRoot and include the XDG items at the end. πŸ¦‹

DestroyMenu MenuFvwmRoot
AddToMenu MenuFvwmRoot "Fvwm" Title
+ "Item1" Action1
  ...
+ "ItemN" ActionN
+ "" Nop
PipeRead 'fvwm2-menu-desktop --insert-in-menu MenuFvwmRoot'

In this case the menu items are inserted at the end of the MenuFvwmRoot menu. if no items are in the menu, this menu becomes MenuFvwmRoot. the problem here tho is that you have to restart fvwm or rebuild the whole menu to Regenerate it, because menu items cannot be removed. πŸ’€ to do this you could use a function like

DestroyFunc XDGRegen
AddToFunc XDGRegen
+ I DestroyMenu MenuFvwmRoot
+ I AddToMenu MenuFvwmRoot "Fvwm" Title
+ I AddToMenu MenuFvwmRoot "Item1" Action1
  ...
+ I AddToMenu MenuFvwmRoot "ItemN" ActionN
+ I AddToMenu MenuFvwmRoot "" Nop
+ I PipeRead 'fvwm2-menu-desktop --insert-in-menu MenuFvwmRoot \
              --regen-cmd XDGRegen'

Fvwm can also create menus dynamically by using DynamicPopUpAction and/or DynamicPopDownAction. these commands, when used with a Menu, will run a Function when the menu is opened. for example one could create the menu XDGMenu when it is opened using

AddToMenu XDGMenu "XDGMenu" Title
+ DynamicPopUpAction PipeRead 'fvwm2-menu-desktop'

This will create the menu when it is opened. one issue here is it will only create the menu the first time it is opened, and you still have to Regenerate the menu to see any changes. πŸ™ˆ to create the menu each time it is opened use the --dynamic option

AddToMenu XDGMenu "XDGMenu" Title
+ DynamicPopUpAction PipeRead 'fvwm2-menu-desktop \
                     --dynamic --include-items config'
+ DynamicPopDownAction DestroyMenu recreate XDGMenu

This will now Destroy the menu when it's closed so it can be rebuilt the next time it is opened. the recreate flag doesn't completely destroy the menu, keeping the DynamicPopUpAction and DynamicPopDownAction actions. and the --dynamic flag includes the recreate option in the generated menus. ✨

To insert a menu into MenuFvwmRoot and still be dynamic you need to use a function that generates the whole menu. for example

DestroyFunc GenRootMenu
AddToFunc GenRootMenu
+ I DestroyMenu recreate MenuFvwmRoot
+ I AddToMenu MenuFvwmRoot "Fvwm" Title
+ I AddToMenu MenuFvwmRoot "Item1" Action1
  ...
+ I AddToMenu MenuFvwmRoot "ItemN" ActionN
+ I AddToMenu MenuFvwmRoot "" Nop
+ PipeRead `fvwm2-menu-desktop --insert-in-menu MenuFvwmRoot \
           --include-items config`

AddToMenu MenuFvwmRoot "Fvwm" Title
+ DynamicPopUpAction GenRootMenu
+ DynamicPopDownAction DestroyMenu recreate MenuFvwmRoot

πŸ’€ BUGS πŸ’€

ngl the whole process of creating menus from files is slow. otherwise report bugs to the fvwm-workers mailing list <fvwm-workers@fvwm.org>. 🫢


πŸ‘‘ AUTHORS πŸ‘‘

This script is based on fvwm-xdg-menu.py written by Piotr Zielinski (http://www.cl.cam.ac.uk/~pz215/) who assigned Licence: GPL 2 Date: 03.12.2005. iconic behaviour tbh.

The script was reworked to replace the existing fvwm-menu-desktop perl script by the fvwm-workers. πŸ’…


πŸŽ€ COPYING πŸŽ€

The script is distributed by the same terms as fvwm itself. See GNU General Public License for details.


and that's a wrap bestie!! 🌈 this was fvwm2-menu-desktop(1) from the 3rd Berkeley Distribution, dated 19 October 2022 (2.7.0). go build a gorgeous menu, you got this πŸ’–πŸŽ€βœ¨