aboutsummaryrefslogtreecommitdiffstats
path: root/menu/xdg_menu
diff options
context:
space:
mode:
Diffstat (limited to 'menu/xdg_menu')
-rwxr-xr-xmenu/xdg_menu996
1 files changed, 459 insertions, 537 deletions
diff --git a/menu/xdg_menu b/menu/xdg_menu
index 06e1b20..2280e79 100755
--- a/menu/xdg_menu
+++ b/menu/xdg_menu
@@ -38,9 +38,8 @@ my @save_ARGV = @ARGV;
my %Desktop_entries;
my %Directory_entries;
-sub check_file ($)
-{
- my ($file) =@_;
+sub check_file ($) {
+ my ($file) = @_;
unless (-e $file) {
push @accessed_files, "X $file";
@@ -56,16 +55,15 @@ sub check_file ($)
}
}
-sub findicon
-{
+sub findicon {
# my $theme = "hicolor";
my $iconname = shift;
- my $home = $ENV{"HOME"};
- my $xdg_data_dirs = $ENV{"XDG_DATA_DIRS"};
+ my $home = $ENV{HOME};
+ my $xdg_data_dirs = $ENV{XDG_DATA_DIRS};
my (@xdg_data_dirs);
@xdg_data_dirs = split(":",$xdg_data_dirs);
@@ -78,37 +76,35 @@ sub findicon
my (@sizelist);
@sizelist = (16, 22, 24, 26, 32, 36, 48, 64, 72, 128, 192, 256);
- my $thisdir = $home."/.icons";
- ( -d $thisdir ) && push @icon_search_path, $thisdir;
+ my $thisdir = $home . "/.icons";
+ -d $thisdir and push @icon_search_path, $thisdir;
foreach my $dir (@xdg_data_dirs)
{
my $theme = "hicolor";
- my $size;
- my $category;
- foreach $size (@sizelist)
+ foreach my $size (@sizelist)
{
- foreach $category (@categorylist)
+ foreach my $category (@categorylist)
{
- $thisdir = $dir."/icons/".$theme."/".$size."x".$size."/".$category;
- ( -d $thisdir ) && push @icon_search_path, $thisdir;
+ $thisdir = join($dir, "/icons/", $theme, "/", $size, "x", $size, "/", $category);
+ -d $thisdir and push @icon_search_path, $thisdir;
}
}
- $thisdir = $dir."/icons/mini";
- ( -d $thisdir ) && push @icon_search_path, $thisdir;
- $thisdir = $dir."/icons";
- ( -d $thisdir ) && push @icon_search_path, $thisdir;
- $thisdir = $dir."/icons/large";
- ( -d $thisdir ) && push @icon_search_path, $thisdir;
+ $thisdir = $dir . "/icons/mini";
+ -d $thisdir and push @icon_search_path, $thisdir;
+ $thisdir = $dir . "/icons";
+ -d $thisdir and push @icon_search_path, $thisdir;
+ $thisdir = $dir . "/icons/large";
+ -d $thisdir and push @icon_search_path, $thisdir;
$theme = "gnome";
- foreach $size (@sizelist)
+ foreach my $size (@sizelist)
{
- foreach $category (@categorylist)
+ foreach my $category (@categorylist)
{
- $thisdir = $dir."/icons/".$theme."/".$size."x".$size."/".$category;
- ( -d $thisdir ) && push @icon_search_path, $thisdir;
+ $thisdir = "$dir/icons/$theme/${size}x$size/$category";
+ -d $thisdir and push @icon_search_path, $thisdir;
}
}
}
@@ -117,75 +113,68 @@ sub findicon
my $filename;
- if ( -f $iconname )
- {
+ if (-f $iconname) {
return $iconname;
- }
- else
- {
+ } else {
foreach my $dir (@icon_search_path)
{
- foreach my $ext ('','.png','.xpm')
+ foreach my $ext ('', '.png', '.xpm')
{
- $filename = $dir."/".$iconname.$ext;
- ( -f $filename ) && return $filename;
+ $filename = "$dir/$iconname$ext";
+ return $filename if -f $filename;
}
}
}
}
-sub add_png_extension_if_needed ($)
-{
+sub add_png_extension_if_needed ($) {
my ($f) = @_;
return $f =~ /\.(png|xpm|svg)$/ ? $f : "$f.png";
}
-sub scan_AppDir ($$;$)
-{
- my ($pool, $dir, $topdir) = @_;
+sub scan_AppDir ($$;$) {
+ my ($pool, $dir, $o_topdir) = @_;
check_file($dir);
- $topdir = $dir unless defined $topdir;
+ $o_topdir = $dir unless defined $o_topdir;
- opendir(DIR, $dir) or return;
+ opendir(my $DIR, $dir) or return;
- foreach my $entry (readdir(DIR)) {
+ foreach my $entry (readdir($DIR)) {
- if ( -f "$dir/$entry" && $entry =~ /\.desktop$/ ) {
- read_desktop_entry($pool, "$dir/$entry", $topdir);
+ if (-f "$dir/$entry" && $entry =~ /\.desktop$/) {
+ read_desktop_entry($pool, "$dir/$entry", $o_topdir);
}
- elsif ( -d "$dir/$entry" && $entry ne '.' && $entry ne '..' && $entry ne '.hidden') {
- scan_AppDir ($pool, "$dir/$entry", $topdir);
+ elsif (-d "$dir/$entry" && $entry ne '.' && $entry ne '..' && $entry ne '.hidden') {
+ scan_AppDir($pool, "$dir/$entry", $o_topdir);
}
}
- closedir DIR;
+ closedir $DIR;
}
-sub scan_DirectoryDir ($$;$)
-{
- my ($pool, $dir, $topdir) = @_;
+sub scan_DirectoryDir ($$;$) {
+ my ($pool, $dir, $o_topdir) = @_;
check_file($dir);
- $topdir = $dir unless defined $topdir;
+ $o_topdir = $dir unless defined $o_topdir;
- opendir(DIR, $dir) or return;
+ opendir(my $DIR, $dir) or return;
- foreach my $entry (readdir(DIR)) {
+ foreach my $entry (readdir($DIR)) {
- if ( -f "$dir/$entry" && $entry =~ /\.directory$/ ) {
- read_directory_entry($pool, "$dir/$entry", $topdir);
+ if (-f "$dir/$entry" && $entry =~ /\.directory$/) {
+ read_directory_entry($pool, "$dir/$entry", $o_topdir);
}
- elsif ( -d "$dir/$entry" && $entry ne '.' && $entry ne '..' && $entry ne '.hidden') {
- scan_DirectoryDir ($pool, "$dir/$entry", $topdir);
+ elsif (-d "$dir/$entry" && $entry ne '.' && $entry ne '..' && $entry ne '.hidden') {
+ scan_DirectoryDir($pool, "$dir/$entry", $o_topdir);
}
}
- closedir DIR;
+ closedir $DIR;
}
-sub read_directory_entry
-{
+sub read_directory_entry {
my ($pool, $file, $topdir) = @_;
@@ -193,11 +182,12 @@ sub read_directory_entry
check_file($file);
- open(FILE, "<$file") or return;
+ open(my $FILE, "<$file") or return;
my $in_desktop_entry = 0;
my %entry;
- while (<FILE>) {
+ local $_;
+ while (<$FILE>) {
if (/^\[/) {
if (/^\[Desktop Entry\]/) {
$in_desktop_entry = 1;
@@ -210,24 +200,23 @@ sub read_directory_entry
$entry{$1} = $2;
}
}
- close(FILE);
+ close($FILE);
my $id = $file;
$id =~ s/^$topdir//;
- $id =~ s/^\/*//;
- $id =~ s/\//-/g;
- $entry{'id'} = $id;
+ $id =~ s!^/*!!;
+ $id =~ s!/!-!g;
+ $entry{id} = $id;
$Directory_entries{$file} = \%entry;
}
my $entry = $Directory_entries{$file};
- $pool->{'Directory_entries'}{$entry->{'id'}} = $entry;
+ $pool->{Directory_entries}{$entry->{id}} = $entry;
}
-sub check_show_in ($)
-{
+sub check_show_in ($) {
my ($entry) = @_;
return 1 unless defined $entry;
@@ -235,24 +224,23 @@ sub check_show_in ($)
my %OnlyShowIn;
my %NotShowIn;
- if (defined $entry->{'OnlyShowIn'}) {
- foreach my $showin (split /;/, $entry->{'OnlyShowIn'}) {
+ if (defined $entry->{OnlyShowIn}) {
+ foreach my $showin (split /;/, $entry->{OnlyShowIn}) {
$OnlyShowIn{$showin} = 1;
}
return 0 unless defined $OnlyShowIn{$desktop_name};
}
- if (defined $entry->{'NotShowIn'}) {
- foreach my $showin (split /;/, $entry->{'NotShowIn'}) {
+ if (defined $entry->{NotShowIn}) {
+ foreach my $showin (split /;/, $entry->{NotShowIn}) {
$NotShowIn{$showin} = 1;
}
- return 0 if defined $NotShowIn{$desktop_name} ;
+ return 0 if defined $NotShowIn{$desktop_name};
}
return 1;
}
-sub read_desktop_entry
-{
+sub read_desktop_entry {
my ($pool, $file, $topdir) = @_;
@@ -260,11 +248,12 @@ sub read_desktop_entry
check_file($file);
- open(FILE, "<$file") or return;
+ open(my $FILE, "<$file") or return;
my $in_desktop_entry = 0;
my %entry;
- while (<FILE>) {
+ local $_;
+ while (<$FILE>) {
if (/^\[/) {
if (/^\[Desktop Entry\]/) {
$in_desktop_entry = 1;
@@ -277,39 +266,38 @@ sub read_desktop_entry
$entry{$1} = $2;
}
}
- close(FILE);
+ close($FILE);
my $id = $file;
$id =~ s/^$topdir//;
- $id =~ s/^\/*//;
- $id =~ s/\//-/g;
- $entry{'id'} = $id;
+ $id =~ s!^/*!!;
+ $id =~ s!/!-!g;
+ $entry{id} = $id;
- $entry{'refcount'} = 0;
+ $entry{refcount} = 0;
$Desktop_entries{$file} = \%entry;
}
my $entry = $Desktop_entries{$file};
- return unless defined $entry->{'Name'};
- return unless defined $entry->{'Exec'};
- return if $entry->{'Hidden'} eq 'true';
- return if $entry->{'NoDisplay'} eq 'true';
-
+ return unless defined $entry->{Name};
+ return unless defined $entry->{Exec};
+ return if $entry->{Hidden} eq 'true';
+ return if $entry->{NoDisplay} eq 'true';
return unless check_show_in($entry);
- return if defined $entry->{'NotShowIn'} && $entry->{'NotShowIn'} eq $desktop_name;
+ return if defined $entry->{NotShowIn} && $entry->{NotShowIn} eq $desktop_name;
if (defined $pool) {
- foreach my $category (split /;/, $entry->{'Categories'}) {
- $pool->{'Categories'}{$category} = [] unless defined $pool->{'Categories'}{$category};
- push @{$pool->{'Categories'}{$category}}, $entry;
+ foreach my $category (split /;/, $entry->{Categories}) {
+ $pool->{Categories}{$category} = [] unless defined $pool->{Categories}{$category};
+ push @{$pool->{Categories}{$category}}, $entry;
}
- $pool->{'Desktop_entries'}{$entry->{'id'}} = $entry;
+ $pool->{Desktop_entries}{$entry->{id}} = $entry;
}
return $entry;
@@ -317,18 +305,17 @@ sub read_desktop_entry
my $cached_pool;
-sub read_desktop_entries ($$)
-{
+sub read_desktop_entries ($$) {
my ($directory_paths, $desktop_paths) = @_;
- if ($cached_pool->{'Directory_paths'} eq $directory_paths &&
- $cached_pool->{'Desktop_paths'} eq $desktop_paths) {
+ if ($cached_pool->{Directory_paths} eq $directory_paths &&
+ $cached_pool->{Desktop_paths} eq $desktop_paths) {
return $cached_pool;
}
- my $pool = {'Desktop_entries' => {},
+ my $pool = {Desktop_entries => {},
'Categories' => {},
'Directory_entries' => {},
'Directory_paths' => $directory_paths,
@@ -350,8 +337,7 @@ sub read_desktop_entries ($$)
return $pool;
}
-sub dump_entry_list ($)
-{
+sub dump_entry_list ($) {
my ($list) = @_;
print "list: ";
@@ -362,21 +348,16 @@ sub dump_entry_list ($)
}
-sub get_directory_entry ($$)
-{
+sub get_directory_entry ($$) {
my ($entry, $pool) = @_;
- return $pool->{'Directory_entries'}{$entry};
+ return $pool->{Directory_entries}{$entry};
}
-sub interpret_Include
-{
+sub interpret_Include {
my ($tree, $entries, $pool) = @_;
my %exist;
- my $i = 0;
-
-
my @list = interpret_entry_node($tree, 'Or', $pool);
foreach my $e (@$entries) {
@@ -392,20 +373,17 @@ sub interpret_Include
next if $exist{$entry};
- push @$entries, {type => 'desktop', desktop => $entry};
- $entry->{'refcount'}++;
+ push @$entries, { type => 'desktop', desktop => $entry };
+ $entry->{refcount}++;
$exist{$entry} = 1;
}
}
-sub interpret_Exclude
-{
+sub interpret_Exclude {
my ($tree, $entries, $pool) = @_;
- my $i = 0;
-
my @list = interpret_entry_node($tree, 'Or', $pool);
@@ -417,7 +395,7 @@ sub interpret_Exclude
if ($exist->{type} eq 'desktop' &&
$exist->{desktop} eq $entry) {
splice @$entries, $i, 1;
- $entry->{'refcount'}--;
+ $entry->{refcount}--;
}
else {
$i++;
@@ -427,22 +405,21 @@ sub interpret_Exclude
}
-sub interpret_entry_node ($$$)
-{
+sub interpret_entry_node ($$$) {
my ($tree, $node, $pool) = @_;
my $i = 0;
- $i++ if (ref($tree->[$i]) eq 'HASH');
+ $i++ if ref($tree->[$i]) eq 'HASH';
my @subtree;
while (defined $tree->[$i]) {
if ($tree->[$i] eq 'Filename') {
$i++;
- if (ref($tree->[$i][0]) eq 'HASH' and $tree->[$i][1] eq '0') {
+ if (ref($tree->[$i][0]) eq 'HASH' && $tree->[$i][1] eq '0') {
my $entry = $tree->[$i][2];
- if (defined $pool->{'Desktop_entries'}{$entry}) {
- push @subtree, [$pool->{'Desktop_entries'}{$entry}];
+ if (defined $pool->{Desktop_entries}{$entry}) {
+ push @subtree, [$pool->{Desktop_entries}{$entry}];
}
else {
push @subtree, [];
@@ -456,10 +433,10 @@ sub interpret_entry_node ($$$)
}
elsif ($tree->[$i] eq 'Category') {
$i++;
- if (ref($tree->[$i][0]) eq 'HASH' and $tree->[$i][1] eq '0') {
+ if (ref($tree->[$i][0]) eq 'HASH' && $tree->[$i][1] eq '0') {
my $category = $tree->[$i][2];
- if (defined $pool->{'Categories'}{$category}) {
- push @subtree, $pool->{'Categories'}{$category};
+ if (defined $pool->{Categories}{$category}) {
+ push @subtree, $pool->{Categories}{$category};
}
else {
push @subtree, [];
@@ -473,8 +450,8 @@ sub interpret_entry_node ($$$)
}
elsif ($tree->[$i] eq 'All') {
$i++;
- if (values %{$pool->{'Desktop_entries'}} > 0) {
- push @subtree, [values %{$pool->{'Desktop_entries'}}];
+ if (scalar %{$pool->{Desktop_entries}}) {
+ push @subtree, [values %{$pool->{Desktop_entries}}];
}
else {
push @subtree, [];
@@ -540,11 +517,11 @@ sub interpret_entry_node ($$$)
$used{$entry} = 1;
}
else {
- $used{$entry} ++
+ $used{$entry}++;
}
}
- $idx ++;
+ $idx++;
}
return () if $cnt == 0;
foreach my $entry (@{$subtree[$min_idx]}) {
@@ -568,7 +545,7 @@ sub interpret_entry_node ($$$)
}
}
return if $cnt == 0;
- foreach my $entry (values %{$pool->{'Desktop_entries'}}) {
+ foreach my $entry (values %{$pool->{Desktop_entries}}) {
push @res, $entry if !defined $used{$entry};
}
@@ -582,9 +559,8 @@ sub interpret_entry_node ($$$)
}
}
-sub interpret_root ($$)
-{
- my ($tree, $topdir) = @_;
+sub interpret_root ($) {
+ my ($tree) = @_;
if ($tree->[0] eq 'Menu') {
return interpret_menu($tree->[1]);
}
@@ -596,12 +572,11 @@ sub interpret_root ($$)
}
-sub interpret_menu ($;$$)
-{
- my ($tree, $directory_paths, $desktop_paths) = @_;
+sub interpret_menu ($;$$) {
+ my ($tree, $o_directory_paths, $o_desktop_paths) = @_;
- $directory_paths = '' unless defined $directory_paths;
- $desktop_paths = '' unless defined $desktop_paths;
+ $o_directory_paths = '' unless defined $o_directory_paths;
+ $o_desktop_paths = '' unless defined $o_desktop_paths;
my %menu = ('entries' => [],
'OnlyUnallocated' => 0,
@@ -610,12 +585,12 @@ sub interpret_menu ($;$$)
my $i = 0;
- $i++ if (ref($tree->[$i]) eq 'HASH');
+ $i++ if ref($tree->[$i]) eq 'HASH';
while (defined $tree->[$i]) {
if ($tree->[$i] eq 'AppDir') {
- if (ref($tree->[$i + 1][0]) eq 'HASH' and $tree->[$i + 1][1] eq '0') {
- $desktop_paths .= ':' . $tree->[$i + 1][2];
+ if (ref($tree->[$i + 1][0]) eq 'HASH' && $tree->[$i + 1][1] eq '0') {
+ $o_desktop_paths .= ':' . $tree->[$i + 1][2];
splice @$tree, $i, 2;
}
else {
@@ -626,12 +601,12 @@ sub interpret_menu ($;$$)
}
}
elsif ($tree->[$i] eq 'DefaultAppDirs') {
- $desktop_paths .= ':' . $DefaultAppDirs;
+ $o_desktop_paths .= ':' . $DefaultAppDirs;
splice @$tree, $i, 2;
}
elsif ($tree->[$i] eq 'DirectoryDir') {
- if (ref($tree->[$i + 1][0]) eq 'HASH' and $tree->[$i + 1][1] eq '0') {
- $directory_paths .= ':' . $tree->[$i + 1][2];
+ if (ref($tree->[$i + 1][0]) eq 'HASH' && $tree->[$i + 1][1] eq '0') {
+ $o_directory_paths .= ':' . $tree->[$i + 1][2];
splice @$tree, $i, 2;
}
else {
@@ -642,7 +617,7 @@ sub interpret_menu ($;$$)
}
}
elsif ($tree->[$i] eq 'DefaultDirectoryDirs') {
- $directory_paths .= ':' . $DefaultDirectoryDirs;
+ $o_directory_paths .= ':' . $DefaultDirectoryDirs;
splice @$tree, $i, 2;
}
else {
@@ -652,27 +627,27 @@ sub interpret_menu ($;$$)
}
- $menu{directory_paths} = $directory_paths;
- $menu{desktop_paths} = $desktop_paths;
+ $menu{directory_paths} = $o_directory_paths;
+ $menu{desktop_paths} = $o_desktop_paths;
- my $pool = read_desktop_entries($directory_paths, $desktop_paths);
+ my $pool = read_desktop_entries($o_directory_paths, $o_desktop_paths);
$i = 0;
- $i++ if (ref($tree->[$i]) eq 'HASH');
+ $i++ if ref($tree->[$i]) eq 'HASH';
while (defined $tree->[$i]) {
if ($tree->[$i] eq 'Menu') {
$i++;
- my $submenu = interpret_menu($tree->[$i], $directory_paths, $desktop_paths);
- push @{$menu{'entries'}}, {type => 'menu', menu => $submenu};
+ my $submenu = interpret_menu($tree->[$i], $o_directory_paths, $o_desktop_paths);
+ push @{$menu{entries}}, { type => 'menu', menu => $submenu };
$i++;
}
elsif ($tree->[$i] eq 'Name') {
$i++;
- if (ref($tree->[$i][0]) eq 'HASH' and $tree->[$i][1] eq '0') {
- $menu{'Name'} = $tree->[$i][2];
+ if (ref($tree->[$i][0]) eq 'HASH' && $tree->[$i][1] eq '0') {
+ $menu{Name} = $tree->[$i][2];
}
else {
print STDERR "wrong Name\n";
@@ -682,8 +657,8 @@ sub interpret_menu ($;$$)
}
elsif ($tree->[$i] eq 'Directory') {
$i++;
- if (ref($tree->[$i][0]) eq 'HASH' and $tree->[$i][1] eq '0') {
- $menu{'Directory'} = get_directory_entry($tree->[$i][2], $pool);
+ if (ref($tree->[$i][0]) eq 'HASH' && $tree->[$i][1] eq '0') {
+ $menu{Directory} = get_directory_entry($tree->[$i][2], $pool);
# print "Directory " . $tree->[$i][2] . "\n";
}
else {
@@ -693,39 +668,39 @@ sub interpret_menu ($;$$)
$i++;
}
elsif ($tree->[$i] eq 'OnlyUnallocated') {
- $menu{'OnlyUnallocated'} = 1;
+ $menu{OnlyUnallocated} = 1;
$i++;
$i++;
}
elsif ($tree->[$i] eq 'DontShowIfEmpty') {
- $menu{'DontShowIfEmpty'} = 1;
+ $menu{DontShowIfEmpty} = 1;
$i++;
$i++;
}
elsif ($tree->[$i] eq 'Deleted') {
- $menu{'Deleted'} = 1;
+ $menu{Deleted} = 1;
$i++;
$i++;
}
elsif ($tree->[$i] eq 'NotDeleted') {
- $menu{'Deleted'} = 0;
+ $menu{Deleted} = 0;
$i++;
$i++;
}
elsif ($tree->[$i] eq 'Include') {
$i++;
- interpret_Include($tree->[$i], $menu{'entries'}, $pool);
+ interpret_Include($tree->[$i], $menu{entries}, $pool);
$i++;
}
elsif ($tree->[$i] eq 'Exclude') {
$i++;
- interpret_Exclude($tree->[$i], $menu{'entries'}, $pool);
+ interpret_Exclude($tree->[$i], $menu{entries}, $pool);
$i++;
}
elsif ($tree->[$i] eq '0') {
$i++;
if ($tree->[$i] !~ /^\s*$/) {
- print STDERR "skip '$tree->[$i]'\n" ;
+ print STDERR "skip '$tree->[$i]'\n";
exit 1 if $die_on_error;
}
$i++;
@@ -743,18 +718,17 @@ sub interpret_menu ($;$$)
}
-sub read_menu ($;$)
-{
- my ($file, $basedir) = @_;
+sub read_menu ($;$) {
+ my ($file, $o_basedir) = @_;
- if ($file !~ /^\// && defined $basedir) {
- $file = "$basedir/$file";
+ if ($file !~ m!^/! && defined $o_basedir) {
+ $file = "$o_basedir/$file";
}
- unless (defined $basedir) {
- $basedir = $file;
- $basedir =~ s/\/[^\/]*$//;
+ unless (defined $o_basedir) {
+ $o_basedir = $file;
+ $o_basedir =~ s!/[^/]*$!!;
}
unless (check_file($file)) {
@@ -768,44 +742,42 @@ sub read_menu ($;$)
my $tree = $parser->parsefile($file);
my $DefaultMergeDir = $file;
- $DefaultMergeDir =~ s/^.*\///;
+ $DefaultMergeDir =~ s!^.*/!!;
$DefaultMergeDir =~ s/\.menu$/-merged/;
- read_includes($tree, $basedir, $DefaultMergeDir);
+ read_includes($tree, $o_basedir, $DefaultMergeDir);
- return $tree
+ return $tree;
}
-sub read_menu_dir ($;$)
-{
+sub read_menu_dir ($;$) {
my ($dir, $basedir) = @_;
my @out;
- if ($dir !~ /^\// && defined $basedir) {
+ if ($dir !~ m!^/! && defined $basedir) {
$dir = "$basedir/$dir";
}
check_file($dir);
- opendir(DIR, $dir);
+ opendir(my $DIR, $dir);
- foreach my $entry (readdir(DIR)) {
+ foreach my $entry (readdir($DIR)) {
- if ( -f "$dir/$entry" && $entry =~ /\.menu$/ ) {
+ if (-f "$dir/$entry" && $entry =~ /\.menu$/) {
my $menu = read_menu("$dir/$entry");
$menu = remove_toplevel_Menu($menu);
push @out, @$menu;
}
}
- closedir DIR;
+ closedir $DIR;
return \@out;
}
-sub quote_xml ($)
-{
+sub quote_xml ($) {
my ($txt) = @_;
$txt =~ s/&/&amp;/g;
@@ -814,20 +786,19 @@ sub quote_xml ($)
return $txt;
}
-sub read_legacy_dir ($;$)
-{
- my ($dir,$basedir) = @_;
+sub read_legacy_dir ($;$) {
+ my ($dir, $o_basedir) = @_;
my $out;
- $dir =~ s/\/*$//;
+ $dir =~ s!/*$!!;
- $basedir = $dir unless defined $basedir;
+ $o_basedir = $dir unless defined $o_basedir;
return "" if check_file($dir) ne 'D';
$out = "<Menu>\n";
- if ($dir eq $basedir) {
+ if ($dir eq $o_basedir) {
my $xmldir = quote_xml($dir);
$out .= "<AppDir>$xmldir</AppDir>\n";
@@ -835,8 +806,8 @@ sub read_legacy_dir ($;$)
}
else {
my $name = $dir;
- $name =~ s/\/*$//;
- $name =~ s/^.*\///;
+ $name =~ s!/*$!!;
+ $name =~ s!^.*/!!;
$name = quote_xml($name);
@@ -847,41 +818,40 @@ sub read_legacy_dir ($;$)
if (-f "$dir/.directory") {
my $dir_id = "$dir/.directory";
- $dir_id =~ s/^$basedir//;
- $dir_id =~ s/^\///;
+ $dir_id =~ s/^$o_basedir//;
+ $dir_id =~ s!^.*/!!;
$dir_id = quote_xml($dir_id);
$out .= "<Directory>$dir_id</Directory>\n";
}
- opendir(DIR, $dir);
+ opendir(my $DIR, $dir);
- foreach my $entry (readdir(DIR)) {
+ foreach my $entry (readdir($DIR)) {
- if ( -f "$dir/$entry" && $entry =~ /\.desktop$/ ) {
+ if (-f "$dir/$entry" && $entry =~ /\.desktop$/) {
my $id = "$dir/$entry";
- $id =~ s/^$basedir//;
- $id =~ s/^\///;
- $id =~ s/\//-/g;
+ $id =~ s/^$o_basedir//;
+ $id =~ s!^.*/!!;
+ $id =~ s!/!-!g;
$id = quote_xml($id);
- my $desktop = read_desktop_entry(undef, "$dir/$entry", $basedir);
- $out .= "<Include><Filename>$id</Filename></Include>\n" unless defined $desktop->{'Categories'}
+ my $desktop = read_desktop_entry(undef, "$dir/$entry", $o_basedir);
+ $out .= "<Include><Filename>$id</Filename></Include>\n" unless defined $desktop->{Categories};
}
- elsif ( -d "$dir/$entry" && $entry ne '.' && $entry ne '..' && $entry ne '.hidden') {
- $out .= read_legacy_dir("$dir/$entry", $basedir);
+ elsif (-d "$dir/$entry" && $entry ne '.' && $entry ne '..' && $entry ne '.hidden') {
+ $out .= read_legacy_dir("$dir/$entry", $o_basedir);
}
}
- closedir DIR;
+ closedir $DIR;
$out .= "</Menu>\n";
return $out;
}
-sub remove_toplevel_Menu ($)
-{
+sub remove_toplevel_Menu ($) {
my ($tree) = @_;
if ($tree->[0] eq 'Menu') {
- shift @{$tree->[1]} if (ref($tree->[1][0]) eq 'HASH');
+ shift @{$tree->[1]} if ref($tree->[1][0]) eq 'HASH';
return $tree->[1];
}
else {
@@ -891,17 +861,16 @@ sub remove_toplevel_Menu ($)
}
}
-sub read_includes ($$$)
-{
+sub read_includes ($$$) {
my ($tree, $basedir, $DefaultMergeDir) = @_;
my $i = 0;
- $i++ if (ref($tree->[$i]) eq 'HASH');
+ $i++ if ref($tree->[$i]) eq 'HASH';
while (defined $tree->[$i]) {
if ($tree->[$i] eq 'MergeFile') {
- if (ref($tree->[$i + 1][0]) eq 'HASH' and $tree->[$i + 1][1] eq '0') {
+ if (ref($tree->[$i + 1][0]) eq 'HASH' && $tree->[$i + 1][1] eq '0') {
my $add_tree = read_menu($tree->[$i + 1][2], $basedir);
$add_tree = remove_toplevel_Menu($add_tree);
@@ -917,7 +886,7 @@ sub read_includes ($$$)
}
elsif ($tree->[$i] eq 'MergeDir') {
- if (ref($tree->[$i + 1][0]) eq 'HASH' and $tree->[$i + 1][1] eq '0') {
+ if (ref($tree->[$i + 1][0]) eq 'HASH' && $tree->[$i + 1][1] eq '0') {
my $add_tree = read_menu_dir($tree->[$i + 1][2], $basedir);
@@ -937,7 +906,7 @@ sub read_includes ($$$)
splice @$tree, $i, 2, @$add_tree;
}
elsif ($tree->[$i] eq 'LegacyDir') {
- if (ref($tree->[$i + 1][0]) eq 'HASH' and $tree->[$i + 1][1] eq '0') {
+ if (ref($tree->[$i + 1][0]) eq 'HASH' && $tree->[$i + 1][1] eq '0') {
my $xml = read_legacy_dir($tree->[$i + 1][2]);
print STDERR "reading legacy directory '" . $tree->[$i + 1][2] . "'\n" if $verbose;
@@ -965,7 +934,7 @@ sub read_includes ($$$)
my $parser = new XML::Parser(Style => 'Tree');
my $add_tree = $parser->parse($xml);
$add_tree = remove_toplevel_Menu($add_tree);
- push @out, @$add_tree
+ push @out, @$add_tree;
}
splice @$tree, $i, 2, @out;
}
@@ -981,19 +950,18 @@ sub read_includes ($$$)
}
}
-sub get_menu_name ($)
-{
+sub get_menu_name ($) {
my ($tree) = @_;
my $name;
my $i = 0;
- $i++ if (ref($tree->[$i]) eq 'HASH');
+ $i++ if ref($tree->[$i]) eq 'HASH';
while (defined $tree->[$i]) {
if ($tree->[$i] eq 'Name') {
$i++;
- if (ref($tree->[$i][0]) eq 'HASH' and $tree->[$i][1] eq '0') {
+ if (ref($tree->[$i][0]) eq 'HASH' && $tree->[$i][1] eq '0') {
$name = $tree->[$i][2];
last;
}
@@ -1015,13 +983,12 @@ sub get_menu_name ($)
}
-sub append_menu ($$)
-{
+sub append_menu ($$) {
my ($target, $source) = @_;
my $i = 0;
- $i++ if (ref($source->[$i]) eq 'HASH');
+ $i++ if ref($source->[$i]) eq 'HASH';
while (defined $source->[$i]) {
if ($source->[$i] ne 'Name') {
@@ -1035,15 +1002,14 @@ sub append_menu ($$)
}
-sub merge_menus ($)
-{
+sub merge_menus ($) {
my ($tree) = @_;
my %used; #menu name already used
my $i = 0;
- $i++ if (ref($tree->[$i]) eq 'HASH');
+ $i++ if ref($tree->[$i]) eq 'HASH';
while (defined $tree->[$i]) {
if ($tree->[$i] eq 'Menu') {
@@ -1069,7 +1035,7 @@ sub merge_menus ($)
$i = 0;
- $i++ if (ref($tree->[$i]) eq 'HASH');
+ $i++ if ref($tree->[$i]) eq 'HASH';
while (defined $tree->[$i]) {
if ($tree->[$i] eq 'Menu') {
@@ -1080,8 +1046,7 @@ sub merge_menus ($)
}
}
-sub read_Move ($$)
-{
+sub read_Move ($$) {
my ($tree, $hash) = @_;
my $i = 0;
@@ -1089,12 +1054,12 @@ sub read_Move ($$)
my $old = '';
- $i++ if (ref($tree->[$i]) eq 'HASH');
+ $i++ if ref($tree->[$i]) eq 'HASH';
while (defined $tree->[$i]) {
if ($tree->[$i] eq 'Old') {
$i++;
- if (ref($tree->[$i][0]) eq 'HASH' and $tree->[$i][1] eq '0') {
+ if (ref($tree->[$i][0]) eq 'HASH' && $tree->[$i][1] eq '0') {
$old = $tree->[$i][2];
}
else {
@@ -1105,7 +1070,7 @@ sub read_Move ($$)
}
if ($tree->[$i] eq 'New') {
$i++;
- if (ref($tree->[$i][0]) eq 'HASH' and $tree->[$i][1] eq '0') {
+ if (ref($tree->[$i][0]) eq 'HASH' && $tree->[$i][1] eq '0') {
$hash->{$old} = $tree->[$i][2];
}
else {
@@ -1121,26 +1086,25 @@ sub read_Move ($$)
}
}
-sub find_menu_in_tree ($$)
-{
+sub find_menu_in_tree ($$) {
my ($path, $tree) = @_;
my $root = $path;
- $root =~ s/\/.*$//;
+ $root =~ s!/.*$!!;
my $subpath = $path;
- $subpath =~ s/^[^\/]*\/*//;
+ $subpath =~ s!^[^/]*/*!!;
my $i = 0;
- $i++ if (ref($tree->[$i]) eq 'HASH');
+ $i++ if ref($tree->[$i]) eq 'HASH';
while (defined $tree->[$i]) {
if ($tree->[$i] eq 'Menu') {
if ($root eq get_menu_name($tree->[$i + 1])) {
if ($subpath eq '') {
- return { 'parent' => $tree, 'index' => $i, 'menu' => $tree->[$i + 1]};
+ return { 'parent' => $tree, 'index' => $i, 'menu' => $tree->[$i + 1] };
}
return find_menu_in_tree($subpath, $tree->[$i + 1]);
}
@@ -1153,14 +1117,13 @@ sub find_menu_in_tree ($$)
return undef;
}
-sub copy_menu ($$)
-{
+sub copy_menu ($$) {
my ($path, $tree) = @_;
my $tail;
my $child;
- foreach my $elem (reverse split(/\//, $path)) {
+ foreach my $elem (reverse split('/', $path)) {
next if $elem eq '';
my $menu = [{}, 'Name', [{}, 0, $elem]];
@@ -1175,8 +1138,7 @@ sub copy_menu ($$)
return $child;
}
-sub move_menus ($)
-{
+sub move_menus ($) {
my ($tree) = @_;
# print "@$tree\n";
@@ -1184,7 +1146,7 @@ sub move_menus ($)
my $i = 0;
- $i++ if (ref($tree->[$i]) eq 'HASH');
+ $i++ if ref($tree->[$i]) eq 'HASH';
while (defined $tree->[$i]) {
if ($tree->[$i] eq 'Move') {
@@ -1202,15 +1164,15 @@ sub move_menus ($)
my $sourceinfo = find_menu_in_tree($source, $tree);
if (defined $sourceinfo) {
- my $target = copy_menu($move{$source}, $sourceinfo->{'menu'});
- splice @{$sourceinfo->{'parent'}}, $sourceinfo->{'index'}, 2;
+ my $target = copy_menu($move{$source}, $sourceinfo->{menu});
+ splice @{$sourceinfo->{parent}}, $sourceinfo->{index}, 2;
push @$tree, ('Menu', $target);
merge_menus($tree);
}
}
$i = 0;
- $i++ if (ref($tree->[$i]) eq 'HASH');
+ $i++ if ref($tree->[$i]) eq 'HASH';
while (defined $tree->[$i]) {
if ($tree->[$i] eq 'Menu') {
@@ -1221,25 +1183,24 @@ sub move_menus ($)
}
}
-sub remove_allocated ($)
-{
+sub remove_allocated ($) {
my ($menu) = @_;
my $i = 0;
- while ($i < @{$menu->{'entries'}}) {
- my $entry = $menu->{'entries'}[$i];
+ while ($i < @{$menu->{entries}}) {
+ my $entry = $menu->{entries}[$i];
if ($entry->{type} eq 'menu') {
remove_allocated($entry->{menu});
$i++;
}
elsif ($entry->{type} eq 'desktop' &&
- $menu->{'OnlyUnallocated'} &&
- $entry->{desktop}{'refcount'} > 1) {
+ $menu->{OnlyUnallocated} &&
+ $entry->{desktop}{refcount} > 1) {
- $entry->{desktop}{'refcount'}--;
- splice @{$menu->{'entries'}}, $i, 1;
+ $entry->{desktop}{refcount}--;
+ splice @{$menu->{entries}}, $i, 1;
}
else {
$i++;
@@ -1251,17 +1212,16 @@ sub remove_allocated ($)
}
-sub remove_empty_menus ($)
-{
+sub remove_empty_menus ($) {
my ($menu) = @_;
my $i = 0;
- while ($i < @{$menu->{'entries'}}) {
- my $entry = $menu->{'entries'}[$i];
+ while ($i < @{$menu->{entries}}) {
+ my $entry = $menu->{entries}[$i];
if ($entry->{type} eq 'menu' && remove_empty_menus($entry->{menu})) {
- splice @{$menu->{'entries'}}, $i, 1;
+ splice @{$menu->{entries}}, $i, 1;
}
else {
$i++;
@@ -1270,14 +1230,13 @@ sub remove_empty_menus ($)
}
- return 1 if @{$menu->{'entries'}} == 0; # && $menu->{'DontShowIfEmpty'}; #menu is empty
+ return 1 if @{$menu->{entries}} == 0; # && $menu->{DontShowIfEmpty}; #menu is empty
return 0;
}
-sub prepare_exec ($$)
-{
+sub prepare_exec ($$) {
my ($exec, $desktop) = @_;
$exec =~ s/%f//g;
@@ -1305,8 +1264,7 @@ sub prepare_exec ($$)
return $exec;
}
-sub get_loc_entry ($$)
-{
+sub get_loc_entry ($$) {
my ($desktop, $entry) = @_;
foreach my $key (@language_keys) {
@@ -1317,87 +1275,86 @@ sub get_loc_entry ($$)
return $desktop->{$entry};
}
-sub preprocess_menu ($)
-{
+sub preprocess_menu ($) {
# localize, sort, prepare_exec
my ($menu) = @_;
- return 0 if $menu->{'Deleted'};
- return 0 unless check_show_in($menu->{'Directory'});
- return 0 if defined $menu->{'Directory'} && $menu->{'Directory'}->{'NoDisplay'} eq 'true';
+ return 0 if $menu->{Deleted};
+ return 0 unless check_show_in($menu->{Directory});
+ return 0 if defined $menu->{Directory} && $menu->{Directory}{NoDisplay} eq 'true';
- my $menu_name = $menu->{'Name'};
+ my $menu_name = $menu->{Name};
my $menu_icon = "";
- if (defined $menu->{'Directory'}) {
- my $directory = $menu->{'Directory'};
- $menu_icon = $menu->{'Directory'}{'Icon'};
+ if (defined $menu->{Directory}) {
+ my $directory = $menu->{Directory};
+ $menu_icon = $menu->{Directory}{Icon};
my $directory_name = get_loc_entry($directory, 'Name');
if (defined $directory_name) {
Encode::from_to($directory_name, "utf8", $charset)
- if !defined $directory->{"Encoding"} || $directory->{"Encoding"} eq 'UTF-8';
+ if !defined $directory->{Encoding} || $directory->{Encoding} eq 'UTF-8';
$menu_name = $directory_name;
}
}
- $menu->{'PrepName'} = $menu_name;
- $menu->{'PrepIcon'} = $menu_icon;
+ $menu->{PrepName} = $menu_name;
+ $menu->{PrepIcon} = $menu_icon;
my $i = 0;
- while (defined $menu->{'entries'}[$i]) {
- my $entry = $menu->{'entries'}[$i];
- if ($entry->{'type'} eq 'desktop') {
+ while (defined $menu->{entries}[$i]) {
+ my $entry = $menu->{entries}[$i];
+ if ($entry->{type} eq 'desktop') {
my $desktop = $entry->{desktop};
- my $name = $desktop->{'id'};
+ my $name = $desktop->{id};
my $desktop_name = get_loc_entry($desktop, 'Name');
if (defined $desktop_name) {
Encode::from_to($desktop_name, "utf8", $charset)
- if !defined $desktop->{"Encoding"} || $desktop->{"Encoding"} eq 'UTF-8';
+ if !defined $desktop->{Encoding} || $desktop->{Encoding} eq 'UTF-8';
$name = $desktop_name;
}
- $desktop->{'PrepName'} = $name;
- $entry->{'Name'} = $name;
- $entry->{'PrepName'} = $name;
+ $desktop->{PrepName} = $name;
+ $entry->{Name} = $name;
+ $entry->{PrepName} = $name;
- $desktop->{'PrepExec'} = prepare_exec($desktop->{Exec}, $desktop);
+ $desktop->{PrepExec} = prepare_exec($desktop->{Exec}, $desktop);
$i++;
}
elsif ($entry->{type} eq 'menu') {
- if (preprocess_menu ($entry->{'menu'})) {
- $entry->{'Name'} = $entry->{'menu'}{'Name'};
- $entry->{'PrepName'} = $entry->{'menu'}{'PrepName'};
+ if (preprocess_menu($entry->{menu})) {
+ $entry->{Name} = $entry->{menu}{Name};
+ $entry->{PrepName} = $entry->{menu}{PrepName};
$i++;
}
else {
- splice @{$menu->{'entries'}}, $i, 1;
+ splice @{$menu->{entries}}, $i, 1;
}
}
else {
print STDERR "wrong menu entry type: $entry->{type}";
exit 1 if $die_on_error;
- splice @{$menu->{'entries'}}, $i, 1;
+ splice @{$menu->{entries}}, $i, 1;
}
}
- $menu->{'entries'} = [ sort {$b->{'type'} cmp $a->{'type'} || $a->{'PrepName'} cmp $b->{'PrepName'}} @{$menu->{'entries'}} ];
+ $menu->{entries} = [ sort { $b->{type} cmp $a->{type} || $a->{PrepName} cmp $b->{PrepName} } @{$menu->{entries}} ];
- my $i = 0;
+ $i = 0;
my $prev_entry;
- while (defined $menu->{'entries'}[$i]) {
- my $entry = $menu->{'entries'}[$i];
+ while (defined $menu->{entries}[$i]) {
+ my $entry = $menu->{entries}[$i];
if (defined $prev_entry &&
- $entry->{'type'} eq 'desktop' &&
- $prev_entry->{'type'} eq 'desktop' &&
- $prev_entry->{'PrepName'} eq $entry->{'PrepName'} &&
- $prev_entry->{'desktop'}->{'PrepExec'} eq $entry->{'desktop'}->{'PrepExec'}) {
- splice @{$menu->{'entries'}}, $i, 1;
+ $entry->{type} eq 'desktop' &&
+ $prev_entry->{type} eq 'desktop' &&
+ $prev_entry->{PrepName} eq $entry->{PrepName} &&
+ $prev_entry->{desktop}{PrepExec} eq $entry->{desktop}{PrepExec}) {
+ splice @{$menu->{entries}}, $i, 1;
}
else {
$prev_entry = $entry;
@@ -1408,52 +1365,51 @@ sub preprocess_menu ($)
return 1;
}
-sub output_twm_menu ($;$$)
-{
- my ($menu, $toplevel, $path) = @_;
+sub output_twm_menu ($;$$) {
+ my ($menu, $o_toplevel, $o_path) = @_;
my $output = '';
- $path = '' unless defined $path;
+ $o_path = '' unless defined $o_path;
- $toplevel = 1 unless defined $toplevel;
+ $o_toplevel = 1 unless defined $o_toplevel;
- my $menu_name = $menu->{'PrepName'};
- my $menu_id = "$path-" . $menu->{'Name'};
+ my $menu_name = $menu->{PrepName};
+ my $menu_id = "$o_path-" . $menu->{Name};
$menu_id =~ s/\s/_/g;
- $menu_id = 'xdg_menu' if $toplevel;
+ $menu_id = 'xdg_menu' if $o_toplevel;
- foreach my $entry (@{$menu->{'entries'}}) {
+ foreach my $entry (@{$menu->{entries}}) {
if ($entry->{type} eq 'menu') {
- $output .= output_twm_menu($entry->{'menu'}, 0, $menu_id);
+ $output .= output_twm_menu($entry->{menu}, 0, $menu_id);
}
}
- $output .= "menu \"$menu_id\" {\n";
- $output .= "\"$menu_name\" f.title\n";
+ $output .= qq(menu "$menu_id" {\n);
+ $output .= qq("$menu_name" f.title);
- foreach my $entry (@{$menu->{'entries'}}) {
+ foreach my $entry (@{$menu->{entries}}) {
if ($entry->{type} eq 'desktop') {
my $desktop = $entry->{desktop};
- my $name = $desktop->{'PrepName'};
- my $exec = $desktop->{'PrepExec'};
+ my $name = $desktop->{PrepName};
+ my $exec = $desktop->{PrepExec};
my $color = '';
$exec =~ s/"/\\"/g;
$color = ' ("red":"grey")' if $desktop->{'X-KDE-SubstituteUID'} eq '1' || $desktop->{'X-KDE-SubstituteUID'} eq 'true';
- $output .= "\"$name\"$color f.exec \"$exec&\"\n";
+ $output .= qq("$name"$color f.exec "$exec&"\n);
}
elsif ($entry->{type} eq 'menu') {
- my $name = $entry->{'menu'}{'PrepName'};
- my $id = "$menu_id-" . $entry->{'menu'}{'Name'};
+ my $name = $entry->{menu}{PrepName};
+ my $id = "$menu_id-" . $entry->{menu}{Name};
$id =~ s/\s/_/g;
- $output .= "\"$name\" f.menu \"$id\"\n";
+ $output .= qq("$name" f.menu "$id"\n);
}
else {
print STDERR "wrong menu entry type: $entry->{type}";
@@ -1465,36 +1421,35 @@ sub output_twm_menu ($;$$)
return $output;
}
-sub output_wmaker_menu ($;$)
-{
- my ($menu, $indent) = @_;
+sub output_wmaker_menu ($;$) {
+ my ($menu, $o_indent) = @_;
my $output = '';
- $indent = 0 unless defined $indent;
+ $o_indent = 0 unless defined $o_indent;
- my $menu_name = $menu->{'PrepName'};
+ my $menu_name = $menu->{PrepName};
- $output .= ' ' x $indent;
- $output .= "\"$menu_name\" MENU\n";
+ $output .= ' ' x $o_indent;
+ $output .= qq("$menu_name" MENU\n);
- if ($indent == 0) {
- $output .= "\n#include \"user.menu\"\n\n";
+ if ($o_indent == 0) {
+ $output .= qq(\n#include "user.menu"\n\n);
}
- foreach my $entry (@{$menu->{'entries'}}) {
+ foreach my $entry (@{$menu->{entries}}) {
if ($entry->{type} eq 'desktop') {
my $desktop = $entry->{desktop};
- my $name = $desktop->{'PrepName'};
- my $exec = $desktop->{'PrepExec'};
+ my $name = $desktop->{PrepName};
+ my $exec = $desktop->{PrepExec};
- $output .= ' ' x $indent;
- $output .= " \"$name\" EXEC $exec\n";
+ $output .= ' ' x $o_indent;
+ $output .= qq( "$name" EXEC $exec\n);
}
elsif ($entry->{type} eq 'menu') {
- $output .= output_wmaker_menu ($entry->{'menu'}, $indent + 1);
+ $output .= output_wmaker_menu($entry->{menu}, $o_indent + 1);
}
else {
print STDERR "wrong menu entry type: $entry->{type}";
@@ -1502,7 +1457,7 @@ sub output_wmaker_menu ($;$)
}
- if ($indent == 0) {
+ if ($o_indent == 0) {
textdomain("menu-messages");
my $exit_msg = gettext("Exit");
@@ -1511,55 +1466,54 @@ sub output_wmaker_menu ($;$)
$exit_msg = Encode::encode_utf8($exit_msg);
$restart_msg = Encode::encode_utf8($restart_msg);
}
- $output .= "\t\"$exit_msg\" MENU\n\t\t\"$restart_msg\" RESTART\n\t\t\"$exit_msg\" EXIT\n\"$exit_msg\" END\n";
+ $output .= qq(\t"$exit_msg" MENU\n\t\t"$restart_msg" RESTART\n\t\t"$exit_msg" EXIT\n"$exit_msg" END\n);
}
- $output .= ' ' x $indent;
- $output .= "\"$menu_name\" END\n";
+ $output .= ' ' x $o_indent;
+ $output .= qq("$menu_name" END\n);
return $output;
}
-sub output_fvwm2_menu ($;$$)
-{
- my ($menu, $toplevel, $path) = @_;
+sub output_fvwm2_menu ($;$$) {
+ my ($menu, $o_toplevel, $o_path) = @_;
my $output = '';
- $path = '' unless defined $path;
+ $o_path = '' unless defined $o_path;
- $toplevel = 1 unless defined $toplevel;
+ $o_toplevel = 1 unless defined $o_toplevel;
- my $menu_name = $menu->{'PrepName'};
- my $menu_id = "$path-" . $menu->{'Name'};
+ my $menu_name = $menu->{PrepName};
+ my $menu_id = "$o_path-" . $menu->{Name};
$menu_id =~ s/\s/_/g;
- $menu_id = 'xdg_menu' if $toplevel;
+ $menu_id = 'xdg_menu' if $o_toplevel;
- foreach my $entry (@{$menu->{'entries'}}) {
+ foreach my $entry (@{$menu->{entries}}) {
if ($entry->{type} eq 'menu') {
- $output .= output_fvwm2_menu($entry->{'menu'}, 0, $menu_id);
+ $output .= output_fvwm2_menu($entry->{menu}, 0, $menu_id);
}
}
- $output .= "DestroyMenu \"$menu_id\"\n";
- $output .= "AddToMenu \"$menu_id\" \"$menu_name\" Title\n";
+ $output .= qq(DestroyMenu "$menu_id"\n);
+ $output .= qq(AddToMenu "$menu_id" "$menu_name" Title\n);
- foreach my $entry (@{$menu->{'entries'}}) {
+ foreach my $entry (@{$menu->{entries}}) {
if ($entry->{type} eq 'desktop') {
my $desktop = $entry->{desktop};
- my $name = $desktop->{'PrepName'};
- my $exec = $desktop->{'PrepExec'};
+ my $name = $desktop->{PrepName};
+ my $exec = $desktop->{PrepExec};
- $output .= "+ \"$name\" Exec $exec\n";
+ $output .= qq(+ "$name" Exec $exec\n);
}
elsif ($entry->{type} eq 'menu') {
- my $name = $entry->{'menu'}{'PrepName'};
- my $id = "$menu_id-" . $entry->{'menu'}{'Name'};
+ my $name = $entry->{menu}{PrepName};
+ my $id = "$menu_id-" . $entry->{menu}{Name};
$id =~ s/\s/_/g;
- $output .= "+ \"$name\" Popup \"$id\"\n";
+ $output .= qq(+ "$name" Popup "$id"\n);
}
else {
print STDERR "wrong menu entry type: $entry->{type}";
@@ -1571,15 +1525,14 @@ sub output_fvwm2_menu ($;$$)
return $output;
}
-sub output_blackbox_menu ($;$)
-{
- my ($menu, $indent) = @_;
+sub output_blackbox_menu ($;$) {
+ my ($menu, $o_indent) = @_;
my $output = '';
my $run = $format eq 'fluxbox' ? 'fbrun -nearmouse' : 'bbrun -a -w';
$output .= "[begin] (Menu)\n";
- $output .= output_blackbox_inner_menu ($menu, $indent);
+ $output .= output_blackbox_inner_menu($menu, $o_indent);
$output .= "[separator]\n";
$output .= '[config] (Configuration)
[workspaces] (Workspace)
@@ -1605,88 +1558,85 @@ sub output_blackbox_menu ($;$)
}
-sub output_blackbox_inner_menu ($;$)
-{
- my ($menu, $indent) = @_;
+sub output_blackbox_inner_menu ($;$) {
+ my ($menu, $o_indent) = @_;
my $output = '';
- $indent = 0 unless defined $indent;
+ $o_indent = 0 unless defined $o_indent;
- my $menu_name = $menu->{'PrepName'};
- $menu_name =~ s/\)/\\\)/g;
- my $menu_icon = findicon($menu->{'PrepIcon'} || "folder");
+ my $menu_name = $menu->{PrepName};
+ $menu_name =~ s/\)/\\)/g;
+ my $menu_icon = findicon($menu->{PrepIcon} || "folder");
- $output .= ' ' x $indent;
+ $output .= ' ' x $o_indent;
$output .= "[submenu] ($menu_name) <$menu_icon>\n";
- foreach my $entry (@{$menu->{'entries'}}) {
+ foreach my $entry (@{$menu->{entries}}) {
if ($entry->{type} eq 'desktop') {
my $desktop = $entry->{desktop};
- my $name = $desktop->{'PrepName'};
- $name =~ s/\)/\\\)/g;
- my $exec = $desktop->{'PrepExec'};
- my $icon = findicon($desktop->{'Icon'});
+ my $name = $desktop->{PrepName};
+ $name =~ s/\)/\\)/g;
+ my $exec = $desktop->{PrepExec};
+ my $icon = findicon($desktop->{Icon});
- $output .= ' ' x $indent;
+ $output .= ' ' x $o_indent;
$output .= " [exec] ($name) {$exec} <$icon>\n";
}
elsif ($entry->{type} eq 'menu') {
- $output .= output_blackbox_inner_menu ($entry->{'menu'}, $indent + 1);
+ $output .= output_blackbox_inner_menu($entry->{menu}, $o_indent + 1);
}
else {
print STDERR "wrong menu entry type: $entry->{type}";
}
}
- $output .= ' ' x $indent;
+ $output .= ' ' x $o_indent;
$output .= "[end] # ($menu_name)\n";
return $output;
}
-sub output_icewm_menu ($;$)
-{
- my ($menu, $indent) = @_;
+sub output_icewm_menu ($;$) {
+ my ($menu, $o_indent) = @_;
my $output = '';
- $indent = 0 unless defined $indent;
+ $o_indent = 0 unless defined $o_indent;
- my $menu_name = $menu->{'PrepName'};
- my $menu_icon = $menu->{'PrepIcon'} || "folder" ;
+ my $menu_name = $menu->{PrepName};
+ my $menu_icon = $menu->{PrepIcon} || "folder";
- $output .= ' ' x $indent;
- $output .= "menu \"$menu_name\" $menu_icon.png {\n";
+ $output .= ' ' x $o_indent;
+ $output .= qq(menu "$menu_name" $menu_icon.png {\n);
- foreach my $entry (@{$menu->{'entries'}}) {
+ foreach my $entry (@{$menu->{entries}}) {
if ($entry->{type} eq 'desktop') {
my $desktop = $entry->{desktop};
- my $name = $desktop->{'PrepName'};
- my $exec = $desktop->{'PrepExec'};
- my $icon = add_png_extension_if_needed($desktop->{'Icon'});
+ my $name = $desktop->{PrepName};
+ my $exec = $desktop->{PrepExec};
+ my $icon = add_png_extension_if_needed($desktop->{Icon});
- $output .= ' ' x $indent;
- $output .= " prog \"$name\" $icon $exec\n";
+ $output .= ' ' x $o_indent;
+ $output .= qq( prog "$name" $icon $exec\n);
}
elsif ($entry->{type} eq 'menu') {
- $output .= output_icewm_menu ($entry->{'menu'}, $indent + 1);
+ $output .= output_icewm_menu($entry->{menu}, $o_indent + 1);
}
else {
print STDERR "wrong menu entry type: $entry->{type}";
}
}
- $output .= ' ' x $indent;
+ $output .= ' ' x $o_indent;
$output .= "}\n";
return $output;
}
-sub prepare_exec_xfce4 ($$)
-{
+sub prepare_exec_xfce4 ($$) {
my ($exec, $desktop) = @_;
$exec =~ s/%f//g;
@@ -1708,7 +1658,7 @@ sub prepare_exec_xfce4 ($$)
$exec =~ s/%%/%/g;
- $exec =~ s/\"/&quot;/g;
+ $exec =~ s/"/&quot;/g;
$exec = "$root_cmd $exec" if $desktop->{'X-KDE-SubstituteUID'} eq '1' || $desktop->{'X-KDE-SubstituteUID'} eq 'true';
return $exec;
@@ -1716,54 +1666,53 @@ sub prepare_exec_xfce4 ($$)
-sub output_xfce4_menu ($;$)
-{
- my ($menu, $indent) = @_;
+sub output_xfce4_menu ($;$) {
+ my ($menu, $o_indent) = @_;
my $output = '';
- $indent = 0 unless defined $indent;
+ $o_indent = 0 unless defined $o_indent;
- if ($indent == 0) {
+ if ($o_indent == 0) {
$output .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$output .= '<!DOCTYPE xfdesktop-menu [' . "\n";
$output .= ' <!ENTITY menu2 SYSTEM "menu2.xml">' . "\n";
$output .= ']>' . "\n\n";
}
- my $menu_name = $menu->{'PrepName'};
- my $menu_ico = $menu->{'PrepIcon'};
- $output .= ' ' x $indent;
+ my $menu_name = $menu->{PrepName};
+ my $menu_ico = $menu->{PrepIcon};
+ $output .= ' ' x $o_indent;
- if ($indent == 0) {
- $output .= "<xfdesktop-menu>\n"
+ if ($o_indent == 0) {
+ $output .= "<xfdesktop-menu>\n";
}
else {
- $output .= "<menu name=\"" . quote_xml($menu_name) ."\" visible=\"yes\" icon=\"${menu_ico}.png \">\n";
+ $output .= qq(<menu name=") . quote_xml($menu_name) . qq(" visible="yes" icon="${menu_ico}.png ">\n");
}
- foreach my $entry (@{$menu->{'entries'}}) {
+ foreach my $entry (@{$menu->{entries}}) {
if ($entry->{type} eq 'desktop') {
my $desktop = $entry->{desktop};
- my $name = $desktop->{'PrepName'};
+ my $name = $desktop->{PrepName};
my $exec = prepare_exec_xfce4($desktop->{Exec}, $desktop);
- my $term = ($desktop->{Terminal} eq '1' || $desktop->{Terminal} eq 'true') ? "yes" : "no";
- my $ico = $desktop->{'Icon'};
- $output .= ' ' x $indent;
- $output .= " <app name=\"" . quote_xml($name) ."\" cmd=\"$exec\" icon=\"$ico\" term=\"$term\"/>\n";
+ my $term = $desktop->{Terminal} eq '1' || $desktop->{Terminal} eq 'true' ? "yes" : "no";
+ my $ico = $desktop->{Icon};
+ $output .= ' ' x $o_indent;
+ $output .= qq( <app name=") . quote_xml($name) . qq(" cmd="$exec" icon="$ico" term="$term"/>\n);
}
elsif ($entry->{type} eq 'menu') {
- $output .= output_xfce4_menu ($entry->{'menu'}, $indent + 1);
+ $output .= output_xfce4_menu($entry->{menu}, $o_indent + 1);
}
else {
print STDERR "wrong menu entry type: $entry->{type}";
}
}
- $output .= ' ' x $indent;
+ $output .= ' ' x $o_indent;
- if ($indent == 0) {
+ if ($o_indent == 0) {
$output .= "</xfdesktop-menu>\n";
}
else {
@@ -1773,9 +1722,8 @@ sub output_xfce4_menu ($;$)
return $output;
}
-sub output_openbox3_menu ($;$)
-{
- my ($menu, $indent) = @_;
+sub output_openbox3_menu ($;$) {
+ my ($menu, $o_indent) = @_;
my $output = '';
@@ -1785,8 +1733,8 @@ sub output_openbox3_menu ($;$)
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://openbox.org/
file:///usr/share/openbox/menu.xsd">';
- $output .= "<menu id=\"xdg\" label=\"xdg\">\n";
- $output .= output_openbox3_inner_menu ($menu, $indent);
+ $output .= qq(<menu id="xdg" label="xdg">\n);
+ $output .= output_openbox3_inner_menu($menu, $o_indent);
$output .= "</menu>\n";
$output .= ' <menu id="root-menu" label="Openbox 3">
<item label="xterm">
@@ -1809,9 +1757,8 @@ sub output_openbox3_menu ($;$)
return $output;
}
-sub output_openbox3_submenu ($;$)
-{
- my ($menu, $indent) = @_;
+sub output_openbox3_submenu ($;$) {
+ my ($menu, $o_indent) = @_;
my $output = '';
@@ -1821,96 +1768,93 @@ sub output_openbox3_submenu ($;$)
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://openbox.org/
file:///usr/share/openbox/menu.xsd">';
- $output .= "<menu id=\"xdg\" label=\"xdg\">\n";
- $output .= output_openbox3_inner_menu ($menu, $indent);
+ $output .= qq(<menu id="xdg" label="xdg">\n);
+ $output .= output_openbox3_inner_menu($menu, $o_indent);
$output .= "</menu>\n";
$output .= "</openbox_menu>\n";
return $output;
}
-sub output_openbox3_pipe_menu ($;$)
-{
- my ($menu, $indent) = @_;
+sub output_openbox3_pipe_menu ($;$) {
+ my ($menu, $o_indent) = @_;
my $output = '';
$output .= "<openbox_pipe_menu>\n";
- $output .= output_openbox3_inner_menu ($menu, $indent);
+ $output .= output_openbox3_inner_menu($menu, $o_indent);
$output .= "</openbox_pipe_menu>\n";
return $output;
}
-sub output_openbox3_inner_menu ($;$)
-{
- my ($menu, $indent, $lastmenu) = @_;
+sub output_openbox3_inner_menu ($;$) {
+ my ($menu, $o_indent, $lastmenu) = @_;
my $output = '';
- $indent = 0 unless defined $indent;
- my $menu_name = $menu->{'PrepName'};
+ $o_indent = 0 unless defined $o_indent;
+ my $menu_name = $menu->{PrepName};
- $output .= ' ' x $indent;
- $output .= "<menu id=\"" . quote_xml($menu_name) . quote_xml($lastmenu) . "\" label=\"".quote_xml($menu_name) . "\">\n";
+ $output .= ' ' x $o_indent;
+ $output .= qq(<menu id=") . quote_xml($menu_name) . quote_xml($lastmenu) . qq(" label=") . quote_xml($menu_name) . qq(">\n);
# $output .= "<menu label=\"".quote_xml($menu_name) . "\">\n";
$lastmenu = $menu_name;
- foreach my $entry (@{$menu->{'entries'}}) {
+ foreach my $entry (@{$menu->{entries}}) {
if ($entry->{type} eq 'desktop') {
my $desktop = $entry->{desktop};
- my $name = $desktop->{'PrepName'};
- my $exec = $desktop->{'PrepExec'};
+ my $name = $desktop->{PrepName};
+ my $exec = $desktop->{PrepExec};
- $output .= ' ' x $indent;
- $output .= " <item label=\"". quote_xml($name)."\">\n";
- $output .= " <action name=\"Execute\"><execute>$exec</execute></action>\n";
+ $output .= ' ' x $o_indent;
+ $output .= qq( <item label=") . quote_xml($name) . qq(">\n);
+ $output .= qq( <action name="Execute"><execute>$exec</execute></action>\n);
$output .= " </item>\n";
}
elsif ($entry->{type} eq 'menu') {
- $output .= output_openbox3_inner_menu ($entry->{'menu'}, $indent + 1, $lastmenu);
+ $output .= output_openbox3_inner_menu($entry->{menu}, $o_indent + 1, $lastmenu);
}
else {
print STDERR "wrong menu entry type: $entry->{type}";
}
}
- $output .= ' ' x $indent;
+ $output .= ' ' x $o_indent;
$output .= "</menu> <!-- $menu_name -->\n";
return $output;
}
-sub output_readable ($;$)
-{
- my ($menu, $indent) = @_;
+sub output_readable ($;$) {
+ my ($menu, $o_indent) = @_;
my $output = '';
- $indent = 0 unless defined $indent;
+ $o_indent = 0 unless defined $o_indent;
- my $menu_name = $menu->{'Name'};
+ my $menu_name = $menu->{Name};
- $output .= "\t" x $indent;
- $output .= "\"$menu_name\" MENU\n";
+ $output .= "\t" x $o_indent;
+ $output .= qq("$menu_name" MENU\n);
- foreach my $entry (@{$menu->{'entries'}}) {
+ foreach my $entry (@{$menu->{entries}}) {
if ($entry->{type} eq 'desktop') {
my $desktop = $entry->{desktop};
my $name = $desktop->{Name};
- $output .= "\t" x $indent;
- $output .= "\t\"$name\"\n";
+ $output .= "\t" x $o_indent;
+ $output .= qq(\t"$name"\n);
my @v = %$desktop;
$output .= "@v\n" if $name eq '';
}
elsif ($entry->{type} eq 'menu') {
- $output .= output_readable ($entry->{menu}, $indent + 1);
+ $output .= output_readable($entry->{menu}, $o_indent + 1);
}
else {
print STDERR "wrong menu entry type: $entry->{type}";
@@ -1921,8 +1865,7 @@ sub output_readable ($;$)
return $output;
}
-sub get_root_menu
-{
+sub get_root_menu() {
foreach my $dir (split(/:/, $ENV{XDG_CONFIG_DIRS}), "/etc/xdg") {
check_file("$dir/menus/applications.menu");
return "$dir/menus/applications.menu" if -f "$dir/menus/applications.menu";
@@ -1930,19 +1873,18 @@ sub get_root_menu
return "";
}
-sub get_app_dirs
-{
+sub get_app_dirs() {
my %used;
my $ret = '';
my @kde_xdgdata = $> ? split(/:/, `kde-config --path xdgdata-apps`) : ();
- foreach $_ (@kde_xdgdata) {
- s/\/applications\/*\s*$//;
- };
+ foreach (@kde_xdgdata) {
+ s!/applications/*\s*$!!;
+ }
foreach my $d (split(/:/, $ENV{XDG_DATA_DIRS}), @kde_xdgdata, "/usr/share", "/opt/gnome/share") {
my $dir = $d;
- $dir =~ s/\/*$//;
+ $dir =~ s!/*$!!;
next if defined $used{$dir};
next if check_file("$dir/applications") ne 'D';
$ret .= ':' if $ret ne '';
@@ -1952,8 +1894,7 @@ sub get_app_dirs
return $ret;
}
-sub get_desktop_dirs
-{
+sub get_desktop_dirs() {
my %used;
my $ret = '';
foreach my $dir (split(/:/, $ENV{XDG_DATA_DIRS}), "/usr/share", "/opt/kde3/share", "/opt/gnome/share") {
@@ -1966,24 +1907,22 @@ sub get_desktop_dirs
return $ret;
}
-sub get_KDE_legacy_dirs
-{
+sub get_KDE_legacy_dirs() {
my %used;
my @ret;
foreach my $d ("/etc/opt/kde3/share/applnk", "/opt/kde3/share/applnk", reverse(split(/:/, `kde-config --path apps`))) {
my $dir = $d;
chomp $dir;
- $dir =~ s/\/*$//;
+ $dir =~ s!/*$!!;
next if defined $used{$dir};
- next if check_file("$dir") ne 'D';
+ next if check_file($dir) ne 'D';
$used{$dir} = 1;
push @ret, $dir;
}
return @ret;
}
-sub prepare_language_keys ($)
-{
+sub prepare_language_keys ($) {
my ($language) = @_;
my @keys;
@@ -2011,8 +1950,7 @@ sub prepare_language_keys ($)
return @keys;
}
-sub check_cache
-{
+sub check_cache() {
my $cachedir = $> ? $ENV{HOME} : '/var/lib/menu';
return unless -d $cachedir;
@@ -2024,11 +1962,12 @@ sub check_cache
my @st = stat "$cachedir/output";
my $ref_time = $st[10]; #ctime
- open(FILE, "<$cachedir/inputs");
+ open(my $FILE, "<$cachedir/inputs");
my $num_opts = 0;
-
- while (<FILE>) {
+
+ local $_;
+ while (<$FILE>) {
chomp;
next if /^\s*$/;
next if /^#/;
@@ -2064,7 +2003,7 @@ sub check_cache
my $optidx = $1;
my $val = $2;
- $num_opts ++;
+ $num_opts++;
if ($save_ARGV[$optidx] ne $val) {
# print STDERR "$optidx: differs\n";
return;
@@ -2104,21 +2043,19 @@ sub check_cache
return if $num_opts != @save_ARGV;
- open(FILE, "<$cachedir/output") or return;
+ open($FILE, "<$cachedir/output") or return;
print STDERR "Using cached output\n" if $verbose;
my $buf;
- while(read(FILE, $buf, 4096)) {
+ while (read($FILE, $buf, 4096)) {
print $buf;
}
- close(FILE);
exit 0;
}
-sub write_cache ($)
-{
+sub write_cache ($) {
my ($output) = @_;
my $cachedir = $> ? $ENV{HOME} : '/var/lib/menu';
@@ -2130,27 +2067,27 @@ sub write_cache ($)
mkdir $cachedir;
unlink "$cachedir/output";
- open(FILE, ">$cachedir/inputs") or return;
- print FILE "# this file contains list of inputs xdg_menu\n";
- print FILE "VERSION $Version\n";
- print FILE "\n\n";
- print FILE join("\n", @accessed_files);
- print FILE "\n\n";
+ open(my $FILE, ">$cachedir/inputs") or return;
+ print $FILE qq(# this file contains list of inputs xdg_menu
+VERSION $Version
+
+
+) . join("\n", @accessed_files);
+ print $FILE "\n\n";
for (my $i = 0; $i < @save_ARGV; $i++) {
- print FILE "OPT $i $save_ARGV[$i]\n";
+ print $FILE "OPT $i $save_ARGV[$i]\n";
}
- print FILE "ENV XDG_CONFIG_DIRS $ENV{XDG_CONFIG_DIRS}\n";
- print FILE "ENV XDG_DATA_DIRS $ENV{XDG_DATA_DIRS}\n";
-
- print FILE "CHARSET " . langinfo(CODESET) . "\n";
- print FILE "LANGUAGE " . setlocale(LC_MESSAGES) . "\n";
+ print $FILE qq(ENV XDG_CONFIG_DIRS $ENV{XDG_CONFIG_DIRS}
+ENV XDG_DATA_DIRS $ENV{XDG_DATA_DIRS}
+CHARSET ) . langinfo(CODESET) . "\n";
+ print $FILE "LANGUAGE " . setlocale(LC_MESSAGES) . "\n";
- close(FILE);
- open(FILE, ">$cachedir/output") or return;
- print FILE $output;
- close(FILE);
+ close($FILE);
+ open($FILE, ">$cachedir/output") or return;
+ print $FILE $output;
+ close($FILE);
}
@@ -2190,7 +2127,7 @@ GetOptions("format=s" => \$format,
$desktop_name = $format unless defined $desktop_name;
if ($help) {
- print <<"EOF";
+ print <<EOF;
xdg-menu - XDG menus for WindowMaker and other window managers
http://freedesktop.org/Standards/menu-spec
@@ -2235,7 +2172,7 @@ EOF
}
-unless ( -f $root_menu) {
+unless (-f $root_menu) {
print STDERR "Can't find root menu file.\n";
exit 1;
}
@@ -2245,7 +2182,7 @@ my $tree = read_menu($root_menu);
merge_menus($tree);
move_menus($tree);
-my $menu = interpret_root($tree, '');
+my $menu = interpret_root($tree);
remove_allocated($menu);
preprocess_menu($menu);
@@ -2255,61 +2192,46 @@ my $output;
if ($format eq 'WindowMaker') {
- $output = output_wmaker_menu($menu)
-}
-elsif ($format eq 'fvwm2') {
+ $output = output_wmaker_menu($menu);
+} elsif ($format eq 'fvwm2') {
- $output = output_fvwm2_menu($menu)
-}
-elsif ($format eq 'icewm') {
- foreach my $entry (@{$menu->{'entries'}}) {
+ $output = output_fvwm2_menu($menu);
+} elsif ($format eq 'icewm') {
+ foreach my $entry (@{$menu->{entries}}) {
if ($entry->{type} eq 'menu') {
- $output .= output_icewm_menu ($entry->{'menu'});
+ $output .= output_icewm_menu($entry->{menu});
}
}
-}
-elsif ($format eq 'xfce4') {
+} elsif ($format eq 'xfce4') {
- $output = output_xfce4_menu($menu)
-}
-elsif ($format eq 'blackbox' || ($format eq 'openbox') || ($format eq 'fluxbox') ) {
+ $output = output_xfce4_menu($menu);
+} elsif ($format eq 'blackbox' || $format eq 'openbox' || $format eq 'fluxbox') {
if ($fullmenu) {
- $output = output_blackbox_menu($menu)
- }
- else
- {
- $output = output_blackbox_inner_menu($menu)
+ $output = output_blackbox_menu($menu);
+ } else {
+ $output = output_blackbox_inner_menu($menu);
}
-}
-elsif ($format eq 'openbox3') {
+} elsif ($format eq 'openbox3') {
if ($fullmenu) {
- $output = output_openbox3_menu($menu)
+ $output = output_openbox3_menu($menu);
+ } else {
+ $output = output_openbox3_submenu($menu);
}
- else
- {
- $output = output_openbox3_submenu($menu)
- }
-}
-elsif ($format eq 'openbox3-pipe') {
+} elsif ($format eq 'openbox3-pipe') {
- $output = output_openbox3_pipe_menu($menu)
-}
-elsif ($format eq 'twm') {
+ $output = output_openbox3_pipe_menu($menu);
+} elsif ($format eq 'twm') {
print STDERR "WARNING: twm does not support umlauts. Parameter --language '' to output plain ASCII.\n" unless $language eq '';
- $output = output_twm_menu($menu)
-}
-elsif ($format eq 'mwm') {
+ $output = output_twm_menu($menu);
+} elsif ($format eq 'mwm') {
- $output = output_twm_menu($menu)
-}
-elsif ($format eq 'readable') {
+ $output = output_twm_menu($menu);
+} elsif ($format eq 'readable') {
- $output = output_readable($menu)
-}
-else
-{
+ $output = output_readable($menu);
+} else {
print STDERR "Unknown format $format\n";
exit 1;
}