Hi,

xdg-open uses "xdg-mime query filetype" to find out the mime type of a given
file. Depending on the desktop environment, xdg-mime uses different backends.
In my case (i3 wm) it falls back to the generic code path, which uses

    file --brief --dereference --mime-type

Since --brief and --dereference are not recognized, xdg-mime returns an empty
mime type and causes xdg-open to open the given file with a browser instead of
using the preferred application.

The following patch adds --brief and --dereference to file(1) to address this.

Regards,
Ralf

Index: usr.bin/file/file.1
===================================================================
RCS file: /usr/cvs/openbsd/src/usr.bin/file/file.1,v
retrieving revision 1.43
diff -u -u -r1.43 file.1
--- usr.bin/file/file.1 30 Jul 2015 11:13:24 -0000      1.43
+++ usr.bin/file/file.1 20 Dec 2015 11:13:37 -0000
@@ -83,7 +83,7 @@
 .Pp
 The options are as follows:
 .Bl -tag -width indent
-.It Fl b
+.It Fl b , -brief
 Does not prepend filenames to output lines.
 .It Fl c
 Prints a summary of the parsed magic file; usually used for debugging.
@@ -97,7 +97,7 @@
 .Dq text/plain
 rather than
 .Dq ASCII text .
-.It Fl L
+.It Fl L , -dereference
 Causes symlinks to be followed.
 .It Fl s
 Attempts to read block and character device files, not just regular files.
Index: usr.bin/file/file.c
===================================================================
RCS file: /usr/cvs/openbsd/src/usr.bin/file/file.c,v
retrieving revision 1.56
diff -u -u -r1.56 file.c
--- usr.bin/file/file.c 5 Dec 2015 13:18:09 -0000       1.56
+++ usr.bin/file/file.c 20 Dec 2015 10:50:21 -0000
@@ -102,9 +102,11 @@
 static FILE    *magicfp;
 
 static struct option longopts[] = {
-       { "mime",      no_argument, NULL, 'i' },
-       { "mime-type", no_argument, NULL, 'i' },
-       { NULL,        0,           NULL, 0   }
+       { "brief",       no_argument, NULL, 'b' },
+       { "dereference", no_argument, NULL, 'L' },
+       { "mime",        no_argument, NULL, 'i' },
+       { "mime-type",   no_argument, NULL, 'i' },
+       { NULL,          0,           NULL, 0   }
 };
 
 __dead void

Reply via email to