diff --git a/obmenu-generator b/obmenu-generator
index 629d923..1eff60f 100644
--- a/obmenu-generator
+++ b/obmenu-generator
@@ -24,23 +24,20 @@
# Program: obmenu-generator
# License: GPLv3
# Created on: 25 March 2011
-# Latest edit on: 02 April 2015
+# Latest edit on: 02 June 2015
# Website: https://github.com/trizen/obmenu-generator
#use 5.014;
#use strict;
#use warnings;
-require Linux::DesktopFiles;
-
-$Linux::DesktopFiles::VERSION >= 0.09
- || die "Update Linux::DesktopFiles to a newer version! (requires >=0.09)\n";
+require Linux::DesktopFiles; # >= 0.09
my $pkgname = 'obmenu-generator';
-my $version = 0.63;
+my $version = 0.64;
our ($CONFIG, $SCHEMA);
-my $output_h = *STDOUT;
+my $output_h = \*STDOUT;
my ($pipe, $static, $icons, $reconfigure, $update_config, $reconf_openbox);
@@ -430,7 +427,6 @@ STATIC_MENU_HEADER
my %cache;
sub check_icon {
- $_[0] // return '';
$cache{$_[0]} //= ((chr ord($_[0]) eq '/') ? $_[0] : $desk_obj->get_icon_path($_[0])
|| $desk_obj->get_icon_path($CONFIG{missing_icon}));
}
@@ -476,6 +472,12 @@ foreach my $file ($desk_obj->get_desktop_files) {
}
}
+my %entities = (
+ '&' => '&',
+ '"' => '"',
+ '_' => '__',
+ );
+
foreach my $schema (@$SCHEMA) {
if (exists $schema->{cat}) {
exists($categories{my $category = lc($schema->{cat}[0]) =~ tr/_a-z0-9/_/cr}) || next;
@@ -491,26 +493,24 @@ foreach my $schema (@$SCHEMA) {
my $exec = $_->{Exec};
foreach my $key (@{$CONFIG{name_keys}}) {
- $_->{$key} eq "" or do {
+ if ($_->{$key}) {
$name = $_->{$key};
last;
- };
+ }
}
- foreach my $item ($name, $exec) {
- $item =~ tr/"&// && do {
- $item =~ s/&/&/g;
- $item =~ s/"/"/g;
- };
- }
+ # encode the entities
+ $name =~ tr/"&_//
+ && $name =~ s/([&"_])/$entities{$1}/g;
$icons
? <<"ITEM_WITH_ICON"
- - $exec
+
ITEM_WITH_ICON
: <<"ITEM";
- - $exec
+
ITEM
+
} @{$categories{$category}}
)
)
@@ -520,10 +520,10 @@ ITEM
my ($command, $label, $icon) = @{$schema->{item}};
$generated_menu .= $icons
? <<"ITEM_WITH_ICON"
- - $command
+
ITEM_WITH_ICON
: <<"ITEM";
- - $command
+
ITEM
}
elsif (exists $schema->{sep}) {
@@ -576,19 +576,19 @@ RECONFIGURE
EOL
$generated_menu .= <<"CONFIG_MENU";
- - $CONFIG{editor} $openbox_conf/autostart
- - $CONFIG{editor} $openbox_conf/rc.xml
+
+
- - $0 -p
- - $0 -s
- - $0 -p -i
- - $0 -s -i
+
+
+
+
- - $CONFIG{editor} $menufile
- - $CONFIG{editor} $schema_file
- - $CONFIG{editor} $config_file
+
+
+
- - $0 -r
+
CONFIG_MENU
}
diff --git a/schema.pl b/schema.pl
index f0e28ba..6919685 100644
--- a/schema.pl
+++ b/schema.pl
@@ -27,14 +27,14 @@
my $editor = $CONFIG->{editor};
our $SCHEMA = [
+
# COMMAND LABEL ICON
{item => ['xdg-open .', 'File Manager', 'file-manager']},
{item => ['xterm', 'Terminal', 'terminal']},
{item => ['xdg-open http://', 'Web Browser', 'web-browser']},
{item => ['gmrun', 'Run command', 'system-run']},
- {item => ['pidgin', 'Instant messaging', 'system-users']},
- {sep => 'Applications'},
+ {sep => 'Categories'},
# NAME LABEL ICON
{cat => ['utility', 'Accessories', 'applications-utilities']},
@@ -73,38 +73,32 @@
{begin_cat => ['Advanced Settings', 'gnome-settings']},
# Configuration files
- {item => ["$editor ~/.conkyrc", 'Conky RC', $editor]},
- {item => ["$editor ~/.config/tint2/tint2rc", 'Tint2 Panel', $editor]},
+ {item => ["$editor ~/.conkyrc", 'Conky RC', 'text-x-source']},
+ {item => ["$editor ~/.config/tint2/tint2rc", 'Tint2 Panel', 'text-x-source']},
# obmenu-generator category
{begin_cat => ['Obmenu-Generator', 'menu-editor']},
- {item => ["$editor ~/.config/obmenu-generator/schema.pl", 'Menu Schema', $editor]},
- {item => ["$editor ~/.config/obmenu-generator/config.pl", 'Menu Config', $editor]},
+ {item => ["$editor ~/.config/obmenu-generator/schema.pl", 'Menu Schema', 'text-x-source']},
+ {item => ["$editor ~/.config/obmenu-generator/config.pl", 'Menu Config', 'text-x-source']},
{sep => undef},
- {item => ['obmenu-generator -p', 'Generate a pipe menu', 'menu-editor']},
- {item => ['obmenu-generator -s', 'Generate a static menu', 'menu-editor']},
- {item => ['obmenu-generator -p -i', 'Generate a pipe menu with icons', 'menu-editor']},
- {item => ['obmenu-generator -s -i', 'Generate a static menu with icons', 'menu-editor']},
+ {item => ["$0 -p", 'Generate a pipe menu', 'menu-editor']},
+ {item => ["$0 -s -c", 'Generate a static menu', 'menu-editor']},
+ {item => ["$0 -p -i", 'Generate a pipe menu with icons', 'menu-editor']},
+ {item => ["$0 -s -i -c", 'Generate a static menu with icons', 'menu-editor']},
{sep => undef},
- {item => ['obmenu-generator -d', 'Refresh Icon Set', 'gtk-refresh']},
+ {item => ['obmenu-generator -d', 'Refresh Icon Set', 'gtk-refresh']},
{end_cat => undef},
# Openbox category
{begin_cat => ['Openbox', 'openbox']},
- {item => ['openbox --reconfigure', 'Reconfigure Openbox', 'openbox']},
- {item => ["$editor ~/.config/openbox/autostart", 'Openbox Autostart', $editor]},
- {item => ["$editor ~/.config/openbox/rc.xml", 'Openbox RC', $editor]},
- {item => ["$editor ~/.config/openbox/menu.xml", 'Openbox Menu', $editor]},
+ {item => ['openbox --reconfigure', 'Reconfigure Openbox', 'openbox']},
+ {item => ["$editor ~/.config/openbox/autostart", 'Openbox Autostart', 'shellscript']},
+ {item => ["$editor ~/.config/openbox/rc.xml", 'Openbox RC', 'text-xml']},
+ {item => ["$editor ~/.config/openbox/menu.xml", 'Openbox Menu', 'text-xml']},
{end_cat => undef},
- # Pacman category
- {begin_cat => ['Pacman / Servers', 'package-manager-icon']},
- {item => ["gksu $editor /etc/makepkg.conf", 'Makepkg Config', 'start-here']},
- {item => ["gksu $editor /etc/pacman.conf", 'Pacman Config', 'start-here']},
- {item => ["gksu $editor /etc/pacman.d/mirrorlist", 'Pacman Mirrorlist', 'start-here']},
- {end_cat => undef},
{end_cat => undef},
{sep => undef},
@@ -113,4 +107,7 @@
# This option uses the default Openbox's action "Exit"
{exit => ['Exit', 'exit']},
+
+ # This uses the 'oblogout' menu
+ # {item => ['oblogout', 'Exit', 'exit']},
]