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
#!/bin/sh
Usage
/usr/local/bin/fvwm-xdg-menu
LOC="$HOME/.local/share/applications /usr/share/applications /usr/share/applications/kde4 /usr/share/kde4/services"
ICONSIZE=16x16
[ -n “$[MIconSize]” ] && ICONSIZE=’$[MIconSize]’
if [ $# -eq 1 ]; then
for i in $LOC;do
DTFILE="$i/$1"
[ -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
done
else
for i in $LOC;do
DTFILE="$i/$1"
[ -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
done
fi
exit 0
[/code]
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.
scientific