[conspire] exo-open(1), default handler, preferred application

Eric De Mund ead-conspire at ixian.com
Wed Mar 4 05:28:11 PST 2009


All,

I'm lazy. At the command line, I like to type "o myresume.pdf" instead
of "evince myresume.pdf", and "o wholesome-graphic...really.png" instead
of "mirage wholesome-graphic...really.png", where I've aliased "o" to
Xfce's exo-open(1).

So, my questions are:

How does exo-open(1) determine what a file's default handler is, what
the preferred application to launch is? And how in the Sam Hill did a
GIMP upgrade change "o myresume.pdf" to now launch itself (GIMP) rather
than my preferred evince(1)?

After a couple of hours drilling down, today, I finally hit bedrock and
got the answer to these questions; they've bugged me for some time. By
all rights they should have been answered in the anemic exo-open(1) man
page, such as under a FILES section. While I'm at it, there should also
be a SEE ALSO section.

These sections should read:

    FILES
        /usr/share/applications/mimeinfo.cache

    SEE ALSO
        update-desktop-database(1),  which  updates  the  MIME  info
        cache stored  in /usr/share/applications/mimeinfo.cache. See
        <http://www.freedesktop.org/wiki/Software/desktop-file-utils>
        or  view  the   update-desktop-database(1)  source  code  at
        <http://www.freedesktop.org/software/desktop-file-utils/releases/>.
        (Presently, update-desktop-database(1) has no manual page.)

Here's my stab at fleshing this out a little. I'm not crystal clear on
the internal workings of the steps, but here's my very high-level under-
standing. If anyone knows the internal workings, do please share. The
steps:

0.  At package upgrade time, among other times,
    update-desktop-database(1) is called. (It has no man page, but it
    does have a "--help" option. Best though is to view the source code
    under
    <http://www.freedesktop.org/software/desktop-file-utils/releases/>.)
    update-desktop-database(1), part of the desktop-file-utils package,
    updates the MIME info cache stored in
    /usr/share/applications/mimeinfo.cache, from the "MimeType=" lines
    in all the .desktop files in /usr/share/applications. This MIME info
    cache holds the mimetype<->desktop (application) mapping. It's a
    text file, it's human-readable and human-editable, and--happily!--
    edits to it take effect immediately.

1.  exo-open(1) sends a message through the D-Bus message bus saying
    that it has a particular file to open that it needs to know the
    handler for. My read of the output of dbus-monitor(1) shows this
    message to either be a D-Bus "AddMatch" or "GetNameOwner" request.

2.  The result of this request, in the case of myresume.pdf, is
    "application/pdf". Some process reads
    /usr/share/applications/mimeinfo.cache, finds the line:

    application/pdf=evince.desktop;epdfview.desktop;gimp.desktop

    , and plucks off "evince.desktop".

3.  evince(1) is launched, by some process, with myresume.pdf as
    argument.

Info shared FYI,
Eric
--
"An avocado-tone refrigerator would look good on your resume."
--fortune cookie

Eric De Mund   | Ixian Systems           | Jab: eadixian at jabber.org/main
ead at ixian.com  | 650 Castro St, #120-210 | Y!M: ead0002
ixian.com/ead/ | Mountain View, CA 94041 | ICQ: 811788




More information about the conspire mailing list