diff options
Diffstat (limited to 'menu')
-rwxr-xr-x | menu/xdg_menu | 87 |
1 files changed, 85 insertions, 2 deletions
diff --git a/menu/xdg_menu b/menu/xdg_menu index 0ac1768..931b373 100755 --- a/menu/xdg_menu +++ b/menu/xdg_menu @@ -56,6 +56,85 @@ sub check_file ($) } } +sub findicon +{ + +# my $theme = "hicolor"; + + my $iconname = shift; + + + my $home = $ENV{"HOME"}; + my $xdg_data_dirs = $ENV{"XDG_DATA_DIRS"}; + + my (@xdg_data_dirs); + @xdg_data_dirs = split(":",$xdg_data_dirs); + + my (@icon_search_path); + + my (@categorylist); + @categorylist = ("apps", "places", "devices", "actions", "animations", "categories", "emblems", "emotes", "filesystems", "intl", "mimetypes", "status", "stock"); + + 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; + + + + foreach my $dir (@xdg_data_dirs) + { + my $theme = "hicolor"; + my $size; + my $category; + foreach $size (@sizelist) + { + foreach $category (@categorylist) + { + $thisdir = $dir."/icons/".$theme."/".$size."x".$size."/".$category; + ( -d $thisdir ) && 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; + $theme = "gnome"; + foreach $size (@sizelist) + { + foreach $category (@categorylist) + { + $thisdir = $dir."/icons/".$theme."/".$size."x".$size."/".$category; + ( -d $thisdir ) && push @icon_search_path, $thisdir; + } + } + } + + push @icon_search_path, "/usr/share/pixmaps"; + + my $filename; + + if ( -f $iconname ) + { + return $iconname; + } + else + { + + foreach my $dir (@icon_search_path) + { + foreach my $ext ('','.png','.xpm') + { + $filename = $dir."/".$iconname.$ext; + ( -f $filename ) && return $filename; + } + } + } +} + sub add_png_extension_if_needed ($) { my ($f) = @_; @@ -1535,19 +1614,23 @@ sub output_blackbox_inner_menu ($;$) $indent = 0 unless defined $indent; my $menu_name = $menu->{'PrepName'}; + $menu_name =~ s/\)/\\\)/g; + my $menu_icon = findicon($menu->{'PrepIcon'} || "folder"); $output .= ' ' x $indent; - $output .= "[submenu] ($menu_name)\n"; + $output .= "[submenu] ($menu_name) <$menu_icon>\n"; 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'}); $output .= ' ' x $indent; - $output .= " [exec] ($name) {$exec}\n"; + $output .= " [exec] ($name) {$exec} <$icon>\n"; } elsif ($entry->{type} eq 'menu') { $output .= output_blackbox_inner_menu ($entry->{'menu'}, $indent + 1); |