Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 371241
Collapse All | Expand All

(-)fvwm/bin/fvwm-menu-desktop.in (-45 / +86 lines)
Lines 2-7 Link Here
2
2
3
# Modification History
3
# Modification History
4
4
5
# Changed on 05/07/11 by  (dane):
6
# - new option kde_config for alternate name of optional
7
#   kde-config command.
8
# - use kde4-config if kde-config isn't found.
9
# - if no kde-config command at all, use some defaults.
10
5
# Changed on 11/30/10 by  (dane):
11
# Changed on 11/30/10 by  (dane):
6
# - changed DIR filehandles to scalars, they're stepping on each other.
12
# - changed DIR filehandles to scalars, they're stepping on each other.
7
#   was a bug in xdg-menu.
13
#   was a bug in xdg-menu.
Lines 69-77 Link Here
69
# Sergej Pupykin <pupykin.s@gmail.com>
75
# Sergej Pupykin <pupykin.s@gmail.com>
70
#
76
#
71
# >> Copyright (c) 2003 SuSE Linux AG, Nuernberg, Germany. All rights reserved.
77
# >> Copyright (c) 2003 SuSE Linux AG, Nuernberg, Germany. All rights reserved.
72
# >> 
78
# >>
73
# >> Author: nadvornik@suse.cz
79
# >> Author: nadvornik@suse.cz
74
80
81
# FILES:
82
# This script uses the following files if present:
83
#   /usr/share with /applications/
84
#   /opt/gnome/share with /applications/
85
#   kde-config --path xdgdata-apps with /applications/
86
#   /opt/kde3/share with /desktop-directories/
87
#   /opt/gnome/share with /desktop-directories/
88
#   /etc/opt/kde3/share/applnk
89
#   /opt/kde3/share/applnk
90
#   kde-config --path apps
91
#   /etc/xdg
92
75
use 5.008;
93
use 5.008;
76
use strict;
94
use strict;
77
use warnings;
95
use warnings;
Lines 86-92 Link Here
86
eval "use XML::Parser; 1" or die "fvwm-menu-desktop:  XML::Parser not installed.\n";
104
eval "use XML::Parser; 1" or die "fvwm-menu-desktop:  XML::Parser not installed.\n";
87
105
88
my $xdg_data_dirs = $ENV{XDG_DATA_DIRS} || '';
106
my $xdg_data_dirs = $ENV{XDG_DATA_DIRS} || '';
89
my $xdg_config_dirs = $ENV{XDG_CONFIG_DIRS} || '';
90
my @PATH_DIRS = split(':',$ENV{PATH}); # for checking if applications exist
107
my @PATH_DIRS = split(':',$ENV{PATH}); # for checking if applications exist
91
108
92
my $version = '@VERSION@';
109
my $version = '@VERSION@';
Lines 98-103 Link Here
98
my $language = '';
115
my $language = '';
99
my $charset = 'iso-8859-1';
116
my $charset = 'iso-8859-1';
100
my $root_cmd;
117
my $root_cmd;
118
my $kde_cmd;
101
my $die_on_error = 0;
119
my $die_on_error = 0;
102
my $verbose = 0;
120
my $verbose = 0;
103
121
Lines 184-196 Link Here
184
	   "check-app!"               => \&obsolete,
202
	   "check-app!"               => \&obsolete,
185
	   "time-limit=s"             => \&obsolete,
203
	   "time-limit=s"             => \&obsolete,
186
	   "merge-user-menu"          => \&obsolete,
204
	   "merge-user-menu"          => \&obsolete,
187
205
	   "desktop=s"                => \&obsolete,
188
	   "su_gui"  => \$root_cmd,
206
	   "su_gui"                   => \$root_cmd,
189
           "verbose" => \$verbose
207
	   "kde_config"               => \$kde_cmd,
208
           "verbose"                  => \$verbose
190
);
209
);
191
210
192
icon_init();
211
icon_init();
193
212
213
# kde-config helps us find things.
214
# sometimes it has funny names.
215
# we can get by without it.
216
if ( ! defined $kde_cmd) {
217
  foreach ("kde-config", "kde4-config") {
218
    if (check_app($_)) {
219
      $kde_cmd = $_;
220
      last;
221
   }
222
  }
223
}
224
194
$DefaultAppDirs = get_app_dirs();
225
$DefaultAppDirs = get_app_dirs();
195
$DefaultDirectoryDirs = get_desktop_dirs();
226
$DefaultDirectoryDirs = get_desktop_dirs();
196
227
Lines 201-225 Link Here
201
$charset = langinfo(CODESET);
232
$charset = langinfo(CODESET);
202
$language = setlocale(LC_MESSAGES);
233
$language = setlocale(LC_MESSAGES);
203
234
204
if (! defined $root_cmd )
235
if (! defined $root_cmd ) {
205
{
236
  foreach (qw(gnomesu kdesu xdg_menu_su)) {
206
    foreach (qw(gnomesu kdesu xdg_menu_su))
237
    if (check_app($_)) {
207
    {
238
      $root_cmd = $_;
208
	    if (check_app($_))
239
      last;
209
        {
210
	        $root_cmd = $_;
211
	        last;
212
	    }
213
    }
240
    }
241
  }
214
}
242
}
215
243
216
if ($verbose)
244
if ($verbose)
217
{
245
{
218
    warn qq|
246
    warn qq|
219
	DEBUG: root menu is $root_menu
247
	DEBUG: root menu is $root_menu.
220
    DEBUG: charset is $charset.
248
	DEBUG: charset is $charset.
221
	DEBUG: language is $language.
249
	DEBUG: language is $language.
222
	DEBUG: root-cmd is $root_cmd.|;
250
	DEBUG: root-cmd is $root_cmd.|;
251
    if (defined $kde_cmd) {
252
      warn "\tDEBUG: kde-config command is $kde_cmd.";
253
    } else {
254
      warn "\tDEBUG: No kde-config command found, using defaults.";
255
    }
223
}
256
}
224
257
225
@language_keys = prepare_language_keys($language);
258
@language_keys = prepare_language_keys($language);
Lines 589-619 Link Here
589
622
590
    $entry{'refcount'} = 0;
623
    $entry{'refcount'} = 0;
591
    $Desktop_entries{$file} = \%entry;
624
    $Desktop_entries{$file} = \%entry;
625
  } else {
626
    warn "Desktop_entry for $file defined\n" if $verbose;
592
  }
627
  }
593
628
594
  my $entry = $Desktop_entries{$file};
629
  my $entry = $Desktop_entries{$file};
595
630
596
  if (! defined $entry->{'Name'}) { # dje debug
631
  if (! defined $entry->{'Name'} or ! defined $entry->{'Exec'}) {
597
    warn "Name is not defined\n";
632
    warn "Name or Exec is not defined\n";
598
  }
633
  }
599
634
600
  return unless defined $entry->{'Name'};
635
  return unless defined $entry->{'Name'};
601
  return unless defined $entry->{'Exec'};
636
  return unless defined $entry->{'Exec'};
602
637
603
  if (defined $entry->{'Hidden'} and $entry->{'Hidden'} eq 'true') {
638
  if (defined $entry->{'Hidden'} and $entry->{'Hidden'} eq 'true') {
639
    warn "Hidden entry for $file\n" if $verbose;
604
    return;
640
    return;
605
  }
641
  }
606
642
607
  #FIXME, an option for this would be good
643
  #FIXME, an option for this would be good
608
644
609
  if (defined $entry->{'NoDisplay'} and  $entry->{'NoDisplay'} eq 'true') {
645
  if (defined $entry->{'NoDisplay'} and  $entry->{'NoDisplay'} eq 'true') {
646
    warn "NoDisplay entry for $file\n" if $verbose;
610
    return;
647
    return;
611
  }
648
  }
612
649
613
  return unless check_show_in($entry);
650
  if (!check_show_in($entry)) {
651
    warn "entry not shown in $file\n" if $verbose;
652
    return;
653
  }
654
  # return unless check_show_in($entry);
614
655
615
  if (defined $entry->{'NotShowIn'} and
656
  if (defined $entry->{'NotShowIn'} and
616
      $entry->{'NotShowIn'} eq $desktop_name) {
657
      $entry->{'NotShowIn'} eq $desktop_name) {
658
    warn "entry not shown in 2 $file\n" if $verbose;
617
    return;
659
    return;
618
  }
660
  }
619
661
Lines 1045-1050 Link Here
1045
            interpret_Exclude($tree->[$i], $menu{'entries'}, $pool);
1087
            interpret_Exclude($tree->[$i], $menu{'entries'}, $pool);
1046
            $i++;
1088
            $i++;
1047
        }
1089
        }
1090
        elsif ($tree->[$i] eq 'Layout' or $tree->[$i] eq 'DefaultLayout')
1091
        {
1092
            $i+=2;		# Ignore
1093
        }
1048
        elsif ($tree->[$i] eq '0')
1094
        elsif ($tree->[$i] eq '0')
1049
        {
1095
        {
1050
            $i++;
1096
            $i++;
Lines 1085-1095 Link Here
1085
1131
1086
    unless (check_file($file))
1132
    unless (check_file($file))
1087
    {
1133
    {
1088
        warn "WARNING: '$file' does not exist\n";
1134
        warn "WARNING: '$file' does not exist\n" if $verbose;
1089
        return [ 'Menu', [ {} ] ];
1135
        return [ 'Menu', [ {} ] ];
1090
    }
1136
    }
1091
1137
1092
    warn "reading '$file'\n" if $verbose;
1138
    warn "reading menu '$file'\n" if $verbose;
1093
1139
1094
    my $parser = XML::Parser->new(Style => 'Tree');
1140
    my $parser = XML::Parser->new(Style => 'Tree');
1095
    my $tree = $parser->parsefile($file);
1141
    my $tree = $parser->parsefile($file);
Lines 1880-1902 Link Here
1880
1926
1881
sub get_root_menu
1927
sub get_root_menu
1882
{
1928
{
1883
    my @menu_bases = (qw(
1929
    my $xdg_config_dirs = $ENV{XDG_CONFIG_DIRS} || '';
1884
        applications
1930
    my $xdg_menu_prefix = $ENV{XDG_MENU_PREFIX} || '';
1885
        debian-menu
1886
        )
1887
    );
1888
1931
1889
    # XXX - TA:  2011-04-10:  Is it enough to assume only one match here is
1932
    foreach my $dir (split(/:/, $xdg_config_dirs), "/etc/xdg")
1890
    #            sufficient?
1933
    {
1891
    foreach my $dir ( split( /:/, $xdg_config_dirs ), "/etc/xdg" )
1934
        my $menu_file="$dir/menus/${xdg_menu_prefix}applications.menu"; # 
1892
    {
1935
	warn "looking for root menu $menu_file\n" if $verbose;
1893
        foreach my $menu_name (@menu_bases)
1936
        return "$menu_file" if -f "$menu_file";
1894
        {
1895
            check_file("$dir/menus/$menu_name.menu");
1896
            if ( -f "$dir/menus/$menu_name.menu" ) {
1897
                return "$dir/menus/$menu_name.menu";
1898
            }
1899
        }
1900
    }
1937
    }
1901
    return "";
1938
    return "";
1902
}
1939
}
Lines 1906-1915 Link Here
1906
    my %used;
1943
    my %used;
1907
    my $ret = '';
1944
    my $ret = '';
1908
1945
1909
    return $ret unless check_app("kde-config");
1946
    my @kde_xdgdata;
1910
1947
    if ( defined $kde_cmd ) {
1911
    my @kde_xdgdata = split( /:/, `kde-config --path xdgdata-apps` );
1948
      @kde_xdgdata = split( /:/, `$kde_cmd --path xdgdata-apps` );
1912
1949
    } else {
1950
      @kde_xdgdata = ("$ENV{HOME}/.local/share/applications/",
1951
		      "/usr/share/kde-settings/kde-profile/default/share/applications/",
1952
		      "/usr/share/applications/",
1953
		      "/usr/local/share/applications/");
1954
    }
1913
    foreach (@kde_xdgdata)
1955
    foreach (@kde_xdgdata)
1914
    {
1956
    {
1915
        s/\/applications\/*\s*$//;
1957
        s/\/applications\/*\s*$//;
Lines 1962-1971 Link Here
1962
        /opt/kde3/share/applnk
2004
        /opt/kde3/share/applnk
1963
        )
2005
        )
1964
    );
2006
    );
1965
2007
    if ( defined $kde_cmd) {
1966
    if (check_app("kde-config"))
2008
      push @legacy_dirs, reverse(split(/:/,`$kde_cmd --path apps` ));
1967
    {
1968
        push @legacy_dirs, reverse(split(/:/,`kde-config --path apps` ));
1969
    }
2009
    }
1970
2010
1971
    foreach my $d ( @legacy_dirs )
2011
    foreach my $d ( @legacy_dirs )
Lines 2110-2114 Link Here
2110
    print "WARNING: Argument \"$arg\" obsolete.  Ignored.\n";
2150
    print "WARNING: Argument \"$arg\" obsolete.  Ignored.\n";
2111
}
2151
}
2112
# Local Variables:
2152
# Local Variables:
2153
# mode: cperl
2113
# compile-command: "perl fvwm-menu-desktop.in --enable-mini-icons --fvwm-icons"
2154
# compile-command: "perl fvwm-menu-desktop.in --enable-mini-icons --fvwm-icons"
2114
# End:
2155
# End:
(-)fvwm/bin/fvwm-menu-desktop.1.in (-20 / +17 lines)
Lines 61-87 Link Here
61
[ \fB\-\-menu-style\fR \fIname\fR ]
61
[ \fB\-\-menu-style\fR \fIname\fR ]
62
[ \fB\-\-no\-check\-app\fR ]
62
[ \fB\-\-no\-check\-app\fR ]
63
[ \fB\-\-time\-limit\fR \fINUM\fR ]
63
[ \fB\-\-time\-limit\fR \fINUM\fR ]
64
[ \fB\-\-kde_config\fR \fIcommand\fR ]
64
65
65
.SH DESCRIPTION
66
.SH DESCRIPTION
66
This is a perl script which parses GNOME or KDE menus definitions to build
67
This is a perl script which parses XDG (GNOME or KDE) menus definitions to build
67
corresponding fvwm or FvwmGtk menus. The script can also
68
corresponding fvwm menus. The script can also
68
build icon and mini\-icon style commands for the applications.
69
build icon and mini\-icon style commands for the applications.
69
70
70
.SH USAGE
71
.SH USAGE
71
There are a lot of options. However the defaults are, I hope, good
72
There are a lot of options. However the defaults are, I hope, good
72
enough.
73
enough.
73
If you want the KDE system menu in the menu "Utilities" add the
74
If you want the application menu in the menu "Utilities" add the
74
following lines in your .fvwm2rc file:
75
following lines in your .fvwm2rc file:
75
.EX
76
.EX
76
 ...
77
 ...
77
AddToMenu Utilities "KDE System Menu" Popup kde\-sys
78
AddToMenu Utilities "Application Menu" Popup FvwmMenu
78
 ...
79
 ...
79
PipeRead 'fvwm-menu-desktop --desktop kde-sys'
80
PipeRead 'fvwm-menu-desktop'
80
.EE
81
.EE
81
For KDE2 you may have to add --utf8 or --uniconv "charset" (see below).
82
If the KDE mini\-icons are in "mini/"
82
Moreover, with KDE2 you can add --merge-user-menu.
83
If you use KDE version 1 (see below for KDE2) and you want mini\-icons
84
in the menu and if the KDE mini\-icons are in "mini/"
85
relative to your fvwm ImagePath add the option \-\-enable-mini\-icons.
83
relative to your fvwm ImagePath add the option \-\-enable-mini\-icons.
86
(if the KDE mini\-icons are in some other place
84
(if the KDE mini\-icons are in some other place
87
use the \-\-mini\-icons\-path option, e.g., they are in your
85
use the \-\-mini\-icons\-path option, e.g., they are in your
Lines 97-104 Link Here
97
+ DynamicPopupAction PipeRead 'fvwm-menu-desktop --desktop kde-user --enable-mini-icons [--destroy-type dynamic] [other options]'
95
+ DynamicPopupAction PipeRead 'fvwm-menu-desktop --desktop kde-user --enable-mini-icons [--destroy-type dynamic] [other options]'
98
.EE
96
.EE
99
97
100
For GNOME it is natural to use FvwmGtk
98
The following example builds "all" GNOME menus (with some
101
menus. The following example builds "all" GNOME menus (with some
102
mini\-icons in the system menu). You need to specify the
99
mini\-icons in the system menu). You need to specify the
103
GNOME installation prefix if it is not /usr (with the
100
GNOME installation prefix if it is not /usr (with the
104
option \-\-install\-prefix). Moreover, the GNOME icons need to be in your
101
option \-\-install\-prefix). Moreover, the GNOME icons need to be in your
Lines 445-464 Link Here
445
to use the --time-limit option and you should redirect the result into a
442
to use the --time-limit option and you should redirect the result into a
446
file and read this file in your fvwm configuration.
443
file and read this file in your fvwm configuration.
447
.IP "\fB\-\-uniconv-exec\fR \fIexec\fR"
444
.IP "\fB\-\-uniconv-exec\fR \fIexec\fR"
448
Where exec is either iconv or uniconv or internal. Allows to choose the
445
Not used, kept for legacy purposes.
449
program which perform the UTF8 translation in the case of the \-\-uniconv
450
option. The internal method is only available with perl 5.8.0 and better.
451
The default is either internal (if available) or iconv.
452
.IP "\fB\-\-menu-style\fR \fIname\fR"
446
.IP "\fB\-\-menu-style\fR \fIname\fR"
453
By default the generated fvwm menus use the default MenuStyle (i.e., the
447
By default the generated fvwm menus use the default MenuStyle (i.e., the
454
MenuStyle "*"). You can specify another MenuStyle name using this option.
448
MenuStyle "*"). You can specify another MenuStyle name using this option.
455
.IP "\fB\-\-[no]check-app\fR"
449
.IP "\fB\-\-[no]check-app\fR"
456
Either check or don't check that applications to execute are in your path.
450
Not used, kept for legacy purposes.
457
Default is \-\-check-app.
458
.IP "\fB\-\-time-limit\fR \fINUM\fR"
451
.IP "\fB\-\-time-limit\fR \fINUM\fR"
459
Change the internal limit (15 seconds) for running this script
452
Not used, kept for legacy purposes.
460
to NUM seconds, 0 means unlimited running. This limiting may be useful
453
.IP "\fB\-\-kde_config\fR \fIcommand\fR"
461
to cut mistakes with the \-\-dir or \-\-install\-path options.
454
If available, this script uses the command kde-config or kde4-config
455
to find the XDG menus.  If the kde-config command has another name
456
you can use this option to set the command name.
457
If this script can't find any kde-config command, it does it's best to run
458
without it.
462
459
463
.SH BUGS
460
.SH BUGS
464
This script needs more testing to see if all options work well
461
This script needs more testing to see if all options work well

Return to bug 371241