Create own menu from list

Hi there!

I want to create a menu from a list of given application-names…

The idea:
I have a workmenu defined from the system (my system), and the users should customize the first section with own applications.

If there is the file $FVWM_USERDIR/ present, this section should be created.

The content of this file is for example:

$ ls $FVWM_USERDIR/ icedove chromium shotwell tuxpaint

so a script should scan the system for these applications.
are they installed?
which icon?
the application-name in $LANG

and produce only these menu-entries for these applications.
A script should guess and find these applications even if the spelling is different in other languages, and case-insensitive.

I tried to play around with fvwm-menu-desktop. But i got all the time with different options and parameters this error-message for example:

$ fvwm-menu-desktop --desktop gnome-sys WARNING: Argument "desktop" obsolete. Ignored.

Any Ideas?

My idea is to search in the menudefs.hook from xdg-menus, or in the .desktop-files in /usr/share/applications (and other directories from xdg-menu) to produce this selective menu…
But maybe i don’t know an existing tool, and i try to reinvent the wheel… So I’m asking here.



What version of FVWM have you installed? I asking because this error message sounds like from the new fvwm-menu-desktop in CVS.
If so, use ‘man fvwm-menu-desktop’ to get the actual options which are quiet different to the old fvwm-menu-desktop until 2.6.5.

I would prefer the .desktop-files. But this is a huge effort to develop.

Another possibility is to install the newest FVWM from CVS and use fvwm-menu-desktop-config.fpl to get a nice GUI to choose an installed xdg menu from GNOME/KDE/etc. and build a FVWM menu on the fly. See the examples in the manpage of fvwm-menu-desktop.

Or, if you have FVWM <= 2.6.5 use parts of Fvwm-Nightshade 0.6.8. Copy the following scripts to /usr/share/fvwm or in your FVWM userhome:

Also copy bin/fvwm-menu-desktop2 to /usr/bin | /usr/local/bin | $HOME/.local/bin (or whatever local path you have for executables).

For your own apps you could use fvwm/FvwmScript-PersonalMenu. This creates in your userhome a .personal file with the apps you’ve chosen in the tool.
Copy it to /usr/share/fvwm or in your FVWM userhome/FvwmScripts, too.

After that put in your config the following menu snippet]AddToMenu MenuRoot DynamicPopupAction FuncMenuRoot

DestroyFunc FuncMenuRoot
AddToFunc FuncMenuRoot

  • I SetMenuIconSize
  • I DestroyMenu MenuRoot
  • I AddToMenu MenuRoot DynamicPopupAction FuncMenuRoot
  • I AddToMenu MenuRoot “$[gt.Root Menu]” Title
  • I AddToMenu MenuRoot “$[gt.&Personal Applications]%home.svg:$[infostore.MenuIconSize]%” Popup MenuFvwmPersonal
  • I Popup FvwmMenu


Dynamic FvwmMenu sub menu for XDG menus

realized with DynamicPopupAction

AddToMenu FvwmMenu DynamicPopupAction FuncXdgMenusInRoot

DestroyFunc FuncXdgMenusInRoot
AddToFunc FuncXdgMenusInRoot

  • I AddToMenu FvwmMenu DynamicPopupAction FuncXdgMenusInRoot
  • I Test (f $[FVWM_USERDIR]/.menu) Read $[FVWM_USERDIR]/.menu
  • I TestRC (!Match) Test (Version >= 2.6.6) PipeRead ‘fvwm-menu-desktop --insert-in-menu MenuRoot > $[FVWM_USERDIR]/.menu && echo “Read $[FVWM_USERDIR]/.menu”’
  • I TestRC (!Match) PipeRead ‘fvwm-menu-desktop2 --insert-in-menu MenuRoot > $[FVWM_USERDIR]/.menu && echo “Read $[FVWM_USERDIR]/.menu”’


Dynamic personal applications sub menu for favorite apps

realized with DynamicPopupAction

AddToMenu MenuFvwmPersonal DynamicPopupAction FuncMenuFvwmPersonal

DestroyFunc FuncMenuFvwmPersonal
AddToFunc FuncMenuFvwmPersonal

  • I DestroyMenu MenuFvwmPersonal
  • I AddToMenu MenuFvwmPersonal DynamicPopupAction FuncMenuFvwmPersonal
  • I AddToMenu MenuFvwmPersonal “$[gt.Personal Applications]” Title
  • I AddToMenu MenuFvwmPersonal “$[gt.&Configure Personal Applications]%PersonalMenuCreator.svg:$[infostore.MenuIconSize]%” FvwmScript FvwmScript-PersonalMenu
  • I Test (f $[FVWM_USERDIR]/.personal) PipeRead sed -e '/^# personal menu/ d;/^ *$/,$ d' $[FVWM_USERDIR]/.personal[/code]That’s it :wink:


  • Thomas -

The funny thing is, i have got fvwm 2.6.5. Selfbuild from sources from on Debian wheezy.

$ fvwm -V
fvwm 2.6.5 compiled on Feb 15 2013 at 00:48:13
with support for: ReadLine, RPlay, Stroke, XPM, PNG, SVG, Shape, XShm, SM, Bidi text, Xinerama, XRender, XCursor, XFT, NLS

and man fvwm-menus-desktop gives me this options i tried… so the manpage is not up2date… :-/

[code]$ fvwm-menu-desktop -h
A perl script which parses xdg menu definitions to build
the corresponding fvwm menus. The script can also build
Icon and MiniIcon styles for the desktop applications.

Usage: /usr/bin/fvwm-menu-desktop [OPTIONS]
–help show this help and exit
–version show version and exit
–install-prefix DIR install prefix of the desktop
–desktop NAME desktop to build the menu for it:
gnome-sys (default), gnome-user, gnome-redhat, gnome-madriva,
kde-sys, kde-user
–type NAME fvwm (default) or gtk for a FvwmGtk menu
–fvwmgtk-alias NAME FvwmGtk module name, default is FvwmGtk
–title NAME menu title, default depends on --desktop
–name NAME menu name, default depends on --desktop
–merge-user-menu merge the system menu with the user menu
–enable-mini-icons enable mini-icons in menu
–enable-tran-mini-icons enable mini-icons in menu and
translation of foo.png icon names to foo.xpm
–mini-icons-path DIR path of menus icons (relative to your
ImagePath), default is ‘mini/’
–png-icons-path DIR path of .png icons, default is your ImagePath
–tran-mini-icons-path DIR path of menus icons for translation
–check-mini-icons PATH check if the mini icons are in PATH
–icon-toptitle micon:law:place:sidepic:color mini-icon for the top
title and sidepic for the top menu
–icon-title micon:law:place:sidepic:color as above for sub menus
–icon-folder micon:law:place mini-icons for folder item
–icon-app micon:law:place mini-icon for applications item
–wm-icons define menu icon names to use with wm-icons
–enable-style build icons and mini-icons style
–enable-tran-style as above with translation (for FvwmGtk menus)
–icon-style micon:icon:law icons for style
–icons-path DIR define the directory of the icons,
the default is very good
–tran-icons-path DIR similar to the above option.
–check-icons PATH check if the icons are in the PATH
–submenu-name-prefix NAME in general not useful
–dir DIR use path as desktop menu description
–destroy-type FLAG how to destroy menu, valid values:
‘yes’, ‘no’, ‘dynamic’, the default depends on --type
–xterm CMD complete terminal command to run applications
in it, default is ‘xterm -e’
–lang NAME language, default is $LANG
–utf8 For desktop entries coded in UTF-8 (KDE2)
–uniconv Use (un)iconv for UTF-8 translation
–uniconv-exec uniconv or iconv (default)
–menu-style name assign specified MenuStyle name to menus
–[no]check-app [do not] check that apps are in your path
–time-limit NUM limit script running time to NUM seconds
–verbose display debug type info oni STDERR
Short options are ok if not ambiguous: -h, -x, -icon-a.

even the program itself lies about its options… hmmm

Do you mean, the latest nightly-build from
I downloaded the tarball from there…

The rest… i have to look about.

Thanks for your hints, Thomas!!!


No, that’s the correct manpage. But the perl script is a little bit buggy … :confused:

No, I mean the CVS version. The latest nightly build is too old and broken - it hasn’t the fvwm-menu-desktop-config.fpl.

  • Thomas -

I looked into exactly this script, which produces this output with -h… so the help is not that, what the script takes… :-/

This one?

So i have to check for a new version of fvwm… hmmm

No, you have to follow the description under FVWM - CVS Information

But more easier is my suggestion with Fvwm-Nightshade:

  • Thomas -

[Edit]: I forgot the manpage … copy additionally man/fvwm-menu-desktop2.1.gz to /usr/share/man/man1/

Ok… Now i compiled and installed from CVS. And fvwm-menu-desktop is working. :slight_smile:

There should be an update of… Or maybe an valid snapshot… oder an newer release. So Debian can put a newer Fvwm than 2.5 in their repositories…

An now i have to make some research on these new working programs… :smiley:



One year later…

I could solve my problem, how i wanted this long time ago.

I wrote a skript, which searches for and parses the .desktop-files given in a file, and puts out menu-lines for Fvwm, which can be included in the config with “PipeRead”

The syntax in the config-file is:

somename.desktop othername.desktop|default_program

In my config i have 2 different types of menu, produced from the same config-file. One starts the selected application, the other one sets this application as default in infostore with a great function stolen from fvwm-nightshade (thanks thomas!!)

If you use it only to produce a menu, just put in linewise your desktop-files in a config without pipe-sign and the following name. (like first line in example!)

It’s too much code, to post the whole mechanism how i produce my menus. The thing is,

user@debian: $fvwm-xdg-menu gvim.desktop TEST (x gvim) + %vim.svg:$[MIconSize]%"GVim" Exec exec gvim -f

So make a function, which reads your listing of desktop-files in your config, and call it like the example with PipeRead.

The skript:

[code] user@debian: $ cat /usr/bin/fvwm-xdg-menu



LOC="$HOME/.local/share/applications /usr/share/applications /usr/share/applications/kde4 /usr/share/kde4/services"
[ -n “$[MIconSize]” ] && ICONSIZE=’$[MIconSize]’

if [ $# -eq 1 ]; then

for i in $LOC;do
[ -e “$DTFILE” ] || continue
awk -F “=” ‘BEGIN {e=0;te=0;i=0;n=0;t=0}
$1 ~ /^Exec/ {if(e==0){exec=$2;e=1;gsub(/%.+ */,"",exec)}}
$1 ~ /^TryExec/ {if(te==0){tryexec=$2;if (tryexec != //) texec=“TEST (x “tryexec”)”;te=1}}
$1 ~ /^Icon/ {if(i==0){icon=$2;i=1}}
$1 ~ /^Name/ {if(n==0){name=$2;n=1;gsub(/"/,"",name)}}
$1 ~ /^Terminal/ {if(t==0){terminal=$2;t=1}}
END {print texec" + %“icon”.svg:“isize”%"“name”" Exec exec "exec}’ isize="$ICONSIZE" $DTFILE
[ -e “$DTFILE” ] && break


for i in $LOC;do
[ -e “$DTFILE” ] || continue
awk -F “=” ‘BEGIN {e=0;te=0;i=0;n=0;t=0}
$1 ~ /^Exec/ {if(e==0){exec=$2;e=1;gsub(/%.+ */,"",exec)}}
$1 ~ /^TryExec/ {if(te==0){tryexec=$2;if (tryexec != //) texec=“TEST (x “tryexec”)”;te=1}}
$1 ~ /^Icon/ {if(i==0){icon=$2;i=1}}
$1 ~ /^Name/ {if(n==0){name=$2;n=1;gsub(/"/,"",name)}}
$1 ~ /^Terminal/ {if(t==0){terminal=$2;t=1}}
END {print texec" + %“icon”.svg:“isize”%"“name”" FuncWriteInfoStoreToFileAndSet ““defent”” ““exec”” $[FVWM_USERDIR]/.settings"" }’ defent=$2 isize="$ICONSIZE" $DTFILE
[ -e “$DTFILE” ] && echo $DTFILE >&2
[ -e “$DTFILE” ] && break


exit 0

user@debian: $ fvwm-xdg-menu gvim.desktop default_editor TEST (x gvim) + %vim.svg:$[MIconSize]%"GVim" FuncWriteInfoStoreToFileAndSet "default_editor" "gvim -f " $[FVWM_USERDIR]/.settings" /usr/share/applications/gvim.desktop

This is the other output. It produces a menu-entry which sets “gvim -f” as “$[infostore.default_editor]” and writes this in the .settings-File in my $FVWM_USERDIR (=/home/user/.fvwm-verve/.settings), if clicked.