--- fvwm/bin/fvwm-menu-desktop.in 2011-04-16 23:10:58.000000000 +0200 +++ fvwn/bin/fvwm-menu-desktop.in 2011-06-20 14:09:15.523333635 +0200 @@ -2,6 +2,12 @@ # Modification History +# Changed on 05/07/11 by (dane): +# - new option kde_config for alternate name of optional +# kde-config command. +# - use kde4-config if kde-config isn't found. +# - if no kde-config command at all, use some defaults. + # Changed on 11/30/10 by (dane): # - changed DIR filehandles to scalars, they're stepping on each other. # was a bug in xdg-menu. @@ -69,9 +75,21 @@ # Sergej Pupykin # # >> Copyright (c) 2003 SuSE Linux AG, Nuernberg, Germany. All rights reserved. -# >> +# >> # >> Author: nadvornik@suse.cz +# FILES: +# This script uses the following files if present: +# /usr/share with /applications/ +# /opt/gnome/share with /applications/ +# kde-config --path xdgdata-apps with /applications/ +# /opt/kde3/share with /desktop-directories/ +# /opt/gnome/share with /desktop-directories/ +# /etc/opt/kde3/share/applnk +# /opt/kde3/share/applnk +# kde-config --path apps +# /etc/xdg + use 5.008; use strict; use warnings; @@ -86,7 +104,6 @@ eval "use XML::Parser; 1" or die "fvwm-menu-desktop: XML::Parser not installed.\n"; my $xdg_data_dirs = $ENV{XDG_DATA_DIRS} || ''; -my $xdg_config_dirs = $ENV{XDG_CONFIG_DIRS} || ''; my @PATH_DIRS = split(':',$ENV{PATH}); # for checking if applications exist my $version = '@VERSION@'; @@ -98,6 +115,7 @@ my $language = ''; my $charset = 'iso-8859-1'; my $root_cmd; +my $kde_cmd; my $die_on_error = 0; my $verbose = 0; @@ -184,13 +202,26 @@ "check-app!" => \&obsolete, "time-limit=s" => \&obsolete, "merge-user-menu" => \&obsolete, - - "su_gui" => \$root_cmd, - "verbose" => \$verbose + "desktop=s" => \&obsolete, + "su_gui" => \$root_cmd, + "kde_config" => \$kde_cmd, + "verbose" => \$verbose ); icon_init(); +# kde-config helps us find things. +# sometimes it has funny names. +# we can get by without it. +if ( ! defined $kde_cmd) { + foreach ("kde-config", "kde4-config") { + if (check_app($_)) { + $kde_cmd = $_; + last; + } + } +} + $DefaultAppDirs = get_app_dirs(); $DefaultDirectoryDirs = get_desktop_dirs(); @@ -201,25 +232,27 @@ $charset = langinfo(CODESET); $language = setlocale(LC_MESSAGES); -if (! defined $root_cmd ) -{ - foreach (qw(gnomesu kdesu xdg_menu_su)) - { - if (check_app($_)) - { - $root_cmd = $_; - last; - } +if (! defined $root_cmd ) { + foreach (qw(gnomesu kdesu xdg_menu_su)) { + if (check_app($_)) { + $root_cmd = $_; + last; } + } } if ($verbose) { warn qq| - DEBUG: root menu is $root_menu - DEBUG: charset is $charset. + DEBUG: root menu is $root_menu. + DEBUG: charset is $charset. DEBUG: language is $language. DEBUG: root-cmd is $root_cmd.|; + if (defined $kde_cmd) { + warn "\tDEBUG: kde-config command is $kde_cmd."; + } else { + warn "\tDEBUG: No kde-config command found, using defaults."; + } } @language_keys = prepare_language_keys($language); @@ -589,31 +622,40 @@ $entry{'refcount'} = 0; $Desktop_entries{$file} = \%entry; + } else { + warn "Desktop_entry for $file defined\n" if $verbose; } my $entry = $Desktop_entries{$file}; - if (! defined $entry->{'Name'}) { # dje debug - warn "Name is not defined\n"; + if (! defined $entry->{'Name'} or ! defined $entry->{'Exec'}) { + warn "Name or Exec is not defined\n"; } return unless defined $entry->{'Name'}; return unless defined $entry->{'Exec'}; if (defined $entry->{'Hidden'} and $entry->{'Hidden'} eq 'true') { + warn "Hidden entry for $file\n" if $verbose; return; } #FIXME, an option for this would be good if (defined $entry->{'NoDisplay'} and $entry->{'NoDisplay'} eq 'true') { + warn "NoDisplay entry for $file\n" if $verbose; return; } - return unless check_show_in($entry); + if (!check_show_in($entry)) { + warn "entry not shown in $file\n" if $verbose; + return; + } + # return unless check_show_in($entry); if (defined $entry->{'NotShowIn'} and $entry->{'NotShowIn'} eq $desktop_name) { + warn "entry not shown in 2 $file\n" if $verbose; return; } @@ -1045,6 +1087,10 @@ interpret_Exclude($tree->[$i], $menu{'entries'}, $pool); $i++; } + elsif ($tree->[$i] eq 'Layout' or $tree->[$i] eq 'DefaultLayout') + { + $i+=2; # Ignore + } elsif ($tree->[$i] eq '0') { $i++; @@ -1085,11 +1131,11 @@ unless (check_file($file)) { - warn "WARNING: '$file' does not exist\n"; + warn "WARNING: '$file' does not exist\n" if $verbose; return [ 'Menu', [ {} ] ]; } - warn "reading '$file'\n" if $verbose; + warn "reading menu '$file'\n" if $verbose; my $parser = XML::Parser->new(Style => 'Tree'); my $tree = $parser->parsefile($file); @@ -1880,23 +1926,14 @@ sub get_root_menu { - my @menu_bases = (qw( - applications - debian-menu - ) - ); + my $xdg_config_dirs = $ENV{XDG_CONFIG_DIRS} || ''; + my $xdg_menu_prefix = $ENV{XDG_MENU_PREFIX} || ''; - # XXX - TA: 2011-04-10: Is it enough to assume only one match here is - # sufficient? - foreach my $dir ( split( /:/, $xdg_config_dirs ), "/etc/xdg" ) - { - foreach my $menu_name (@menu_bases) - { - check_file("$dir/menus/$menu_name.menu"); - if ( -f "$dir/menus/$menu_name.menu" ) { - return "$dir/menus/$menu_name.menu"; - } - } + foreach my $dir (split(/:/, $xdg_config_dirs), "/etc/xdg") + { + my $menu_file="$dir/menus/${xdg_menu_prefix}applications.menu"; # + warn "looking for root menu $menu_file\n" if $verbose; + return "$menu_file" if -f "$menu_file"; } return ""; } @@ -1906,10 +1943,15 @@ my %used; my $ret = ''; - return $ret unless check_app("kde-config"); - - my @kde_xdgdata = split( /:/, `kde-config --path xdgdata-apps` ); - + my @kde_xdgdata; + if ( defined $kde_cmd ) { + @kde_xdgdata = split( /:/, `$kde_cmd --path xdgdata-apps` ); + } else { + @kde_xdgdata = ("$ENV{HOME}/.local/share/applications/", + "/usr/share/kde-settings/kde-profile/default/share/applications/", + "/usr/share/applications/", + "/usr/local/share/applications/"); + } foreach (@kde_xdgdata) { s/\/applications\/*\s*$//; @@ -1962,10 +2004,8 @@ /opt/kde3/share/applnk ) ); - - if (check_app("kde-config")) - { - push @legacy_dirs, reverse(split(/:/,`kde-config --path apps` )); + if ( defined $kde_cmd) { + push @legacy_dirs, reverse(split(/:/,`$kde_cmd --path apps` )); } foreach my $d ( @legacy_dirs ) @@ -2110,5 +2150,6 @@ print "WARNING: Argument \"$arg\" obsolete. Ignored.\n"; } # Local Variables: +# mode: cperl # compile-command: "perl fvwm-menu-desktop.in --enable-mini-icons --fvwm-icons" # End: --- fvwm/bin/fvwm-menu-desktop.1.in 2007-08-07 22:17:42.000000000 +0200 +++ fvwm/bin/fvwm-menu-desktop.1.in 2011-06-20 14:08:56.656666958 +0200 @@ -61,27 +61,25 @@ [ \fB\-\-menu-style\fR \fIname\fR ] [ \fB\-\-no\-check\-app\fR ] [ \fB\-\-time\-limit\fR \fINUM\fR ] +[ \fB\-\-kde_config\fR \fIcommand\fR ] .SH DESCRIPTION -This is a perl script which parses GNOME or KDE menus definitions to build -corresponding fvwm or FvwmGtk menus. The script can also +This is a perl script which parses XDG (GNOME or KDE) menus definitions to build +corresponding fvwm menus. The script can also build icon and mini\-icon style commands for the applications. .SH USAGE There are a lot of options. However the defaults are, I hope, good enough. -If you want the KDE system menu in the menu "Utilities" add the +If you want the application menu in the menu "Utilities" add the following lines in your .fvwm2rc file: .EX ... -AddToMenu Utilities "KDE System Menu" Popup kde\-sys +AddToMenu Utilities "Application Menu" Popup FvwmMenu ... -PipeRead 'fvwm-menu-desktop --desktop kde-sys' +PipeRead 'fvwm-menu-desktop' .EE -For KDE2 you may have to add --utf8 or --uniconv "charset" (see below). -Moreover, with KDE2 you can add --merge-user-menu. -If you use KDE version 1 (see below for KDE2) and you want mini\-icons -in the menu and if the KDE mini\-icons are in "mini/" +If the KDE mini\-icons are in "mini/" relative to your fvwm ImagePath add the option \-\-enable-mini\-icons. (if the KDE mini\-icons are in some other place use the \-\-mini\-icons\-path option, e.g., they are in your @@ -97,8 +95,7 @@ + DynamicPopupAction PipeRead 'fvwm-menu-desktop --desktop kde-user --enable-mini-icons [--destroy-type dynamic] [other options]' .EE -For GNOME it is natural to use FvwmGtk -menus. The following example builds "all" GNOME menus (with some +The following example builds "all" GNOME menus (with some mini\-icons in the system menu). You need to specify the GNOME installation prefix if it is not /usr (with the option \-\-install\-prefix). Moreover, the GNOME icons need to be in your @@ -445,20 +442,20 @@ to use the --time-limit option and you should redirect the result into a file and read this file in your fvwm configuration. .IP "\fB\-\-uniconv-exec\fR \fIexec\fR" -Where exec is either iconv or uniconv or internal. Allows to choose the -program which perform the UTF8 translation in the case of the \-\-uniconv -option. The internal method is only available with perl 5.8.0 and better. -The default is either internal (if available) or iconv. +Not used, kept for legacy purposes. .IP "\fB\-\-menu-style\fR \fIname\fR" By default the generated fvwm menus use the default MenuStyle (i.e., the MenuStyle "*"). You can specify another MenuStyle name using this option. .IP "\fB\-\-[no]check-app\fR" -Either check or don't check that applications to execute are in your path. -Default is \-\-check-app. +Not used, kept for legacy purposes. .IP "\fB\-\-time-limit\fR \fINUM\fR" -Change the internal limit (15 seconds) for running this script -to NUM seconds, 0 means unlimited running. This limiting may be useful -to cut mistakes with the \-\-dir or \-\-install\-path options. +Not used, kept for legacy purposes. +.IP "\fB\-\-kde_config\fR \fIcommand\fR" +If available, this script uses the command kde-config or kde4-config +to find the XDG menus. If the kde-config command has another name +you can use this option to set the command name. +If this script can't find any kde-config command, it does it's best to run +without it. .SH BUGS This script needs more testing to see if all options work well