On Wed, Apr 27, 2011 at 08:06:10PM +0200, Nathaniel H. Stickney wrote:
> >>> $ fvwm-menu-desktop --desktop kde-sys
> >>> Unknown option: desktop
> >>>
> >>> Nothing else. So, where should I be looking to diagnose this? I use
> Gentoo and fvwm 2.6.1.
> >>>
> >>> fvwm-menu-desktop alone produces no output.
> >>>
> >>> Thanks beforehand.
> 
> For me, on ArchLinux...
> 
> $ fvwm --version
> fvwm 2.7.0 compiled on Apr 15 2011 at 22:28:47
> with support for: ReadLine, Stroke, XPM, PNG, SVG, Shape, XShm, SM,
> Bidi text, XRender, XFT, NLS,
> 
> I also get no menu from fvwm-menu-desktop:
> 
> $ fvwm-menu-desktop
> ERROR: Can't find root menu file.
> 
> >> Yep, tell us what is in /etc/xdg/menus/.
> >>
> >> There should be a applications.menu or debian-menu.menu file.
> 
> > $ ls /etc/xdg/menus/
> > kde-4.6-applications.menu  kde-information.menu  lxde-applications.menu
> 
> $ ls /etc/xdg/menus/
> arch-applications.menu
> 
> >> Also check to see if you have XDG_CONFIG_DIRS set to some value.
> >> In a terminal:
> >>
> >> echo $XDG_CONFIG_DIRS
> 
> $ echo $XDG_CONFIG_DIRS
> /etc/xdg
> 
> Don't know if it helps to have another voice, but I wanted to pass
> along my results as well. As Jesús mentioned, thanks beforehand.

I've not tried this, but does the patch attached help?  I suspect though,
given the recursive nature of the output_fvwm2_menu(), this will double up
menu definitions each and every time you call fvwm-menu-desktop.

Dan -- one for you to look at, assuming this patch hasn't trod on your toes
already, but it might be the way to go -- at least in considering multiple
.menu definition files.

-- Thomas Adam

-- 
"Deep in my heart I wish I was wrong.  But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
? bin/.fvwm-menu-desktop.in.rej.swp
? bin/.fvwm-menu-desktop.in.swp
Index: bin/fvwm-menu-desktop.in
===================================================================
RCS file: /home/cvs/fvwm/fvwm/bin/fvwm-menu-desktop.in,v
retrieving revision 1.14.2.3
diff -u -p -r1.14.2.3 fvwm-menu-desktop.in
--- bin/fvwm-menu-desktop.in	20 Apr 2011 03:13:16 -0000	1.14.2.3
+++ bin/fvwm-menu-desktop.in	27 Apr 2011 19:17:06 -0000
@@ -194,7 +194,8 @@ icon_init();
 $DefaultAppDirs = get_app_dirs();
 $DefaultDirectoryDirs = get_desktop_dirs();
 
-$root_menu = get_root_menu();
+my $root_menus = get_root_menus();
+die "No root menus found.\n" unless @$root_menus;
 
 @KDELegacyDirs = get_KDE_legacy_dirs();
 
@@ -216,7 +217,6 @@ if (! defined $root_cmd )
 if ($verbose)
 {
     warn qq|
-	DEBUG: root menu is $root_menu
     DEBUG: charset is $charset.
 	DEBUG: language is $language.
 	DEBUG: root-cmd is $root_cmd.|;
@@ -224,25 +224,27 @@ if ($verbose)
 
 @language_keys = prepare_language_keys($language);
 
-unless (-f $root_menu)
+foreach my $root_menu ( @$root_menus )
 {
-    warn "ERROR: Can't find root menu file.\n" if $verbose;
-    exit 1;
-}
+    unless (-f $root_menu)
+    {
+        warn "ERROR: Can't find root menu file.\n" if $verbose;
+        exit 1;
+    }
 
-my $tree = read_menu($root_menu);
+    my $tree = read_menu($root_menu);
 
-merge_menus($tree);
-move_menus($tree);
+    merge_menus($tree);
+    move_menus($tree);
 
-my $menu = interpret_root($tree, '');
+    my $menu = interpret_root($tree, '');
 
-remove_allocated($menu);
-preprocess_menu($menu);
-remove_empty_menus($menu);
+    remove_allocated($menu);
+    preprocess_menu($menu);
+    remove_empty_menus($menu);
 
-my $output = output_fvwm2_menu($menu);
-print $output;
+    print output_fvwm2_menu($menu);
+}
 
 # output the menu style
 if ($MENU_STYLE ne "")
@@ -1823,6 +1825,24 @@ sub preprocess_menu
     return 1;
 }
 
+sub tear_down_menus
+{
+    my( $menu ) = @_;
+
+    my $destroy_output = '';
+    my $menu_name = $menu->{'PrepName'};
+    my $menu_id = $menu->{'Name'};
+    $menu_id =~ s/\s/_/g;
+    foreach my $entry ( @{ $menu->{'entries'} } )
+    {
+        if ( $entry->{type} eq 'menu' ) {
+            $destroy_output .= qq|DestroyMenu "$menu_id"\n|;
+        }
+    }
+
+    return $destroy_output;
+}
+
 sub output_fvwm2_menu
 {
     my ($menu, $toplevel, $path) = @_;
@@ -1842,9 +1862,13 @@ sub output_fvwm2_menu
             $output .= output_fvwm2_menu( $entry->{'menu'}, 0, $menu_id );
         }
     }
-    $output .= "DestroyMenu \"$menu_id\"\n";
+    
+    ### TA:  FIXME -- this will double menu definitions on each call to
+    #        fvwm-menu-desktop.
+    ###$output .= "DestroyMenu \"$menu_id\"\n";
     $output .= "AddToMenu \"$menu_id\" \"$dmicon{'fvwm_title'}$label$menu_name\" Title\n";
 
+
     if ($MENU_STYLE ne '')
     {
 	    push @menus_for_style, $menu_id;
@@ -1882,27 +1906,18 @@ sub output_fvwm2_menu
     return $output;
 }
 
-sub get_root_menu
+sub get_root_menus
 {
-    my @menu_bases = (qw(
-        applications
-        debian-menu
-        )
-    );
-
-    # XXX - TA:  2011-04-10:  Is it enough to assume only one match here is
-    #            sufficient?
+    my @menus;
     foreach my $dir ( split( /:/, $xdg_config_dirs ), "/etc/xdg" )
     {
-        foreach my $menu_name (@menu_bases)
+        foreach my $menu_name (glob("$dir/menus/*.menu"))
         {
-            check_file("$dir/menus/$menu_name.menu");
-            if ( -f "$dir/menus/$menu_name.menu" ) {
-                return "$dir/menus/$menu_name.menu";
-            }
+            check_file($menu_name);
+            push @menus, $menu_name if -f $menu_name;
         }
     }
-    return "";
+    return \@menus;
 }
 
 sub get_app_dirs

Reply via email to