tags 497779 + patch kthxbye I've attached a patch that makes mime-support read .desktop files from /usr/share/applications. I've tested it and I am able to use evince (*ahem*) to view PDFs from mutt. I would also like to point out, for the benefit of the submitter, that the entire implementation and testing process took less than an hour.
If the same program has a file in both /usr/lib/mime/packages and /usr/share/applications, the latter is ignored because presumably the maintainer wanted to use the former since they provided it. -- brian m. carlson / brian with sandals: Houston, Texas, US +1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
diff -u mime-support.old/update-mime mime-support-3.52/update-mime
--- mime-support.old/update-mime 2012-03-01 00:49:14.802827192 +0000
+++ mime-support-3.52/update-mime 2012-03-02 00:14:45.470429722 +0000
@@ -24,6 +24,7 @@
$mailcap = "/etc/mailcap";
$mailcapdef = "/usr/lib/mime/mailcap";
$mimedir = "/usr/lib/mime/packages";
+$appsdir = "/usr/share/applications";
$orderfile = "/etc/mailcap.order";
$defpriority = 5;
$localgen = 0;
@@ -63,14 +64,12 @@
%packages;
%priorities;
@order;
-
+$counter=1;
sub ReadEntries
{
- my($pkg,$priority,$counter);
-
- $counter=1;
+ my($pkg,$priority);
# foreach $file (glob "$mimedir/*") {
foreach $file (map { glob $_.'/*' } split ':',$mimedir) {
@@ -111,6 +110,56 @@
}
+sub ReadDesktopEntries
+{
+ my($pkg,$priority);
+
+ foreach $file (map { glob $_.'/*' } split ':',$appsdir) {
+ next if ($file =~ m!(^|/)(\.|\#)|(\~)$!);
+ next unless ($file =~ m/\.desktop$/);
+ ($pkg) = ($file =~ m|/([^/]*)\.desktop$|);
+ print STDERR "$pkg:\n" if $debug;
+
+ next if (defined $packages{$pkg});
+ $packages{$pkg} = [];
+
+ if (open(FILE,"<$file")) {
+ my($terminal, $exec, @types) = ("test=test -n \"\$DISPLAY\"");
+ while (<FILE>) {
+ chomp;
+ next if (m/^\s*$|^\s*\#/);
+ if (m/^Terminal=(\w+)/i) {
+ $terminal = "needsterminal" if ($1 eq "true");
+ }
+ elsif (m/Exec=(.*)$/i) {
+ $exec = $1;
+ $exec =~ s/%[fFuU]/%s/g;
+ $exec .= " %s" if ($exec !~ m/%s/);
+ }
+ elsif (m/MimeType=(.*)/i) {
+ push @types, split(/;/, $1);
+ }
+ }
+ if (!defined($exec) || !scalar(@types)) {
+ close(FILE);
+ next;
+ }
+ foreach $type (@types) {
+ my $entry = "$type; $exec; $terminal";
+ $priority=$defpriority;
+ $entries{$counter} = $entry;
+ push @{$packages{$pkg}},$counter;
+ push @{$priorities{$priority}},$counter;
+ print STDERR "$counter: $entry\n" if $debug;
+ $counter++;
+ }
+ close(FILE);
+ } else {
+ print STDERR "Warning: could not open file '$file' -- $!\n";
+ }
+ }
+}
+
sub ReadOrder
{
@@ -270,6 +319,7 @@
ReadEntries();
+ReadDesktopEntries();
ReadOrder();
@list = OrderEntries();
UpdateMailcap(@list);
signature.asc
Description: Digital signature

