i3-dmenu-desktop: add --entry-type=[name|command|both]
The new default is 'both' to add "GNU Image Manipulation Program" as well as "gimp-2.8" to the menu.
This commit is contained in:
parent
66f7a607f6
commit
f044eb9e90
|
@ -29,11 +29,13 @@ sub slurp {
|
||||||
<$fh>;
|
<$fh>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $entry_type = 'both';
|
||||||
my $dmenu_cmd = 'dmenu -i';
|
my $dmenu_cmd = 'dmenu -i';
|
||||||
my $result = GetOptions(
|
my $result = GetOptions(
|
||||||
'dmenu=s' => \$dmenu_cmd,
|
'dmenu=s' => \$dmenu_cmd,
|
||||||
|
'entry-type=s' => \$entry_type,
|
||||||
'version' => sub {
|
'version' => sub {
|
||||||
say "dmenu-desktop 1.0 © 2012 Michael Stapelberg";
|
say "dmenu-desktop 1.1 © 2012 Michael Stapelberg";
|
||||||
exit 0;
|
exit 0;
|
||||||
},
|
},
|
||||||
'help' => sub {
|
'help' => sub {
|
||||||
|
@ -225,19 +227,26 @@ for my $app (keys %apps) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exists($choices{$name})) {
|
if ($entry_type eq 'name' || $entry_type eq 'both') {
|
||||||
# There are two .desktop files which contain the same “Name” value.
|
if (exists($choices{$name})) {
|
||||||
# I’m not sure if that is allowed to happen, but we disambiguate the
|
# There are two .desktop files which contain the same “Name” value.
|
||||||
# situation by appending “ (2)”, “ (3)”, etc. to the name.
|
# I’m not sure if that is allowed to happen, but we disambiguate the
|
||||||
#
|
# situation by appending “ (2)”, “ (3)”, etc. to the name.
|
||||||
# An example of this happening is exo-file-manager.desktop and
|
#
|
||||||
# thunar-settings.desktop, both of which contain “Name=File Manager”.
|
# An example of this happening is exo-file-manager.desktop and
|
||||||
my $inc = 2;
|
# thunar-settings.desktop, both of which contain “Name=File Manager”.
|
||||||
$inc++ while exists($choices{"$name ($inc)"});
|
my $inc = 2;
|
||||||
$name = "$name ($inc)";
|
$inc++ while exists($choices{"$name ($inc)"});
|
||||||
|
$name = "$name ($inc)";
|
||||||
|
}
|
||||||
|
|
||||||
|
$choices{$name} = $app;
|
||||||
}
|
}
|
||||||
|
|
||||||
$choices{$name} = $app;
|
if ($entry_type eq 'command' || $entry_type eq 'both') {
|
||||||
|
my ($command) = split(' ', $apps{$app}->{Exec});
|
||||||
|
$choices{basename($command)} = $app;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# %choices now looks like this:
|
# %choices now looks like this:
|
||||||
|
@ -378,7 +387,7 @@ system('i3-msg', $cmd) == 0 or die "Could not launch i3-msg: $?";
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
i3-dmenu-desktop [--dmenu='dmenu -i']
|
i3-dmenu-desktop [--dmenu='dmenu -i'] [--entry-type=both]
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
@ -425,11 +434,19 @@ Execute command instead of 'dmenu -i'. This option can be used to pass custom
|
||||||
parameters to dmenu, or to make i3-dmenu-desktop start a custom (patched?)
|
parameters to dmenu, or to make i3-dmenu-desktop start a custom (patched?)
|
||||||
version of dmenu.
|
version of dmenu.
|
||||||
|
|
||||||
|
=item B<--entry-type=type>
|
||||||
|
|
||||||
|
Display the (localized) "Name" (type = name) or the command (type = command) or
|
||||||
|
both (type = both) in dmenu.
|
||||||
|
|
||||||
|
Examples are "GNU Image Manipulation Program" (type = name), "gimp" (type =
|
||||||
|
command) and both (type = both).
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 VERSION
|
=head1 VERSION
|
||||||
|
|
||||||
Version 1.0
|
Version 1.1
|
||||||
|
|
||||||
=head1 AUTHOR
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue