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. |
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; |
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@'; |
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 |
|
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 |
|
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); |
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 |
|
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++; |
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); |
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 |
} |
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*$//; |
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 ) |
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: |