Package: devscripts
Version: 2.10.68
Severity: wishlist
Tags: patch

Hi,

I've been annoyed by the fact that the maintainers of some desktop
environments in Debian have chosen to ignore the Debian menu, chosing
instead to only ship .desktop files, since it would be much work to
write and maintain .menu files for all their packages (as opposed to
.desktop files, which are usually provided by upstream). The unfortunate
result is that software which supports the Debian menu system now no
longer shows all applications that should probably show up in a menu.

Additionally, the GNOME maintainers have chosen to disable the Debian
menu by default, and a conversation on IRC made it clear to me that the
KDE maintainers are considering to do the default. The reason, AIUI, is
that they are of the opinion that it does not add much value, since
usually most of the entries there are already available in the 'regular'
XDG menu system, and that having multiple entries for the same
application can be confusing (e.g., when using the 'search'
functionality in the KDE menu).

This patch tries to remedy both problems:
- It adds a --sects argument with which one can specify a file to
  override the automatically-generated sections. With this, creating a
  menu entry can be done automatically from debian/rules, and the .menu
  file will automatically be updated if upstream changes anything in
  their .desktop file without manual intervention from the maintainer.
- It adds an option 'xdg="false"' to the generated menu entry. In
  conjunction with a patch to the menu-xdg package (which I will file
  separately), this will make menu entries that are autogenerated from
  .desktop files (or ones that are hand-crafted, but have that flag
  specified as well) not appear by default in the XDG menu. This may
  make the "Debian menu" more useful to environments that do understand
  how the .desktop format works, since applications do not show up twice
  and the menu system will not be as bloated.

With these patches, maintainers of packages with .desktop files should
be able to more easily ship .menu files

Regards,

(yes, of course it's fine if you deal with this post-squeeze ;-)

-- 
The biometric identification system at the gates of the CIA headquarters
works because there's a guard with a large gun making sure no one is
trying to fool the system.
  http://www.schneier.com/blog/archives/2009/01/biometrics.html
diff -ruN devscripts-2.10.68/scripts/desktop2menu.pl devscripts-2.10.68.mine/scripts/desktop2menu.pl
--- devscripts-2.10.68/scripts/desktop2menu.pl	2010-09-09 00:47:15.000000000 +0200
+++ devscripts-2.10.68.mine/scripts/desktop2menu.pl	2010-10-23 20:21:28.422078914 +0200
@@ -29,7 +29,7 @@
 
 B<desktop2menu> B<--help|--version>
 
-B<desktop2menu> I<desktop file> [I<package name>]
+B<desktop2menu> [B<--sects> I<section mappings file>] I<desktop file> [I<package name>]
 
 =head1 DESCRIPTION
 
@@ -40,6 +40,13 @@
 argument. If it is not supplied then B<desktop2menu> will attempt to derive 
 the package name from the data in the desktop file.
 
+The section mappings file is a simple file containing pairs of commands
+and sections, separated by an equals sign. If a command that appears in
+the section mappings file is found in the Exec entry, then the section
+in that section mappings file is used as the Debian menu section to put
+the application in, rather than the default that would be guessed based
+upon the Categories entry in the .desktop file.
+
 =head1 LICENSE
 
 This program is Copyright (C) 2007 by Sune Vuorela <deb...@pusling.com>. It 
@@ -209,16 +216,31 @@
     "GTK" => "true",
 );
 
-my ($opt_help, $opt_version);
+my ($opt_help, $opt_version, $opt_sects);
 
 GetOptions("help|h" => \$opt_help,
 	   "version" => \$opt_version,
+	   "sects|s=s" => \$opt_sects,
 	  )
     or die "Usage: $progname desktopfile packagename\nRun $progname --help for more details\n";
 
 if ($opt_help) { help(); exit 0; }
 if ($opt_version) { version(); exit 0; }
 
+my %overrides;
+
+if (defined($opt_sects)) {
+    open SECTS,"<$opt_sects";
+    while(my $map=<SECTS>) {
+        chomp($map);
+	unless($map =~ /([^=]+)=([^=]+)/) {
+	    die "Error: unparsable mapping \"$map\"";
+	}
+	$overrides{$1}=$2;
+    }
+    close SECTS;
+}
+
 if (@ARGV == 0) {
     help();
     exit 0;
@@ -246,6 +268,10 @@
 
 my $category = $file->get_value('Categories');
 
+if (exists($overrides{$file->get_value('Exec')})) {
+    $section = $overrides{$file->get_value('Exec')};
+}
+
 my @categories = reverse split(";", $category);
 foreach (@categories ) {
     if ($mappings{$_} && ! $section) {
@@ -279,6 +305,7 @@
 print "\thints=\"" . join(",", @hints) . "\" \\\n" if @hints;
 print "\tcommand=\"" . $file->get_value('Exec') . "\" \\\n";
 print "\ticon=\"/usr/share/pixmaps/" . $file->get_value('Icon') . ".xpm\" \\\n";
+print "\txdg=\"false\"\n";
 print "\n";
 
 # Unnecessary. but for clarity
@@ -291,6 +318,7 @@
 Valid options are:
    --help, -h             Display this message
    --version, -v          Display version and copyright info
+   --sects, -s <file>     Specify file for section overrides
 EOF
 }
 

Reply via email to