xdg-open is the freedesktop utility, equivalent to "open" on osx or "start" on windows. It's standard, and can open any uri or file according to the spec.<div><br></div><div>The specs you're looking for are the Shared Mime Info spec and the Mime Actions spec. Together, they define:</div>
<div> - How file types are guessed from file names and contents</div><div> - How applications can register themselves to a specific file type or protocol</div><div> - How all that can be modified through tools and how to write those tools.</div>
<div><br clear="all">J. Leclanche<br>
<br><br><div class="gmail_quote">On Sat, Sep 29, 2012 at 10:12 PM, Yfrwlf <span dir="ltr"><<a href="mailto:yfrwlf@gmail.com" target="_blank">yfrwlf@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">
<div bgcolor="#FFFFFF" text="#000000">
Associating programs to file types and protocol URLs cannot be
completely managed by applications as that would not lead to a
smooth and unified user experience. It would also demand that all
applications be more complicated than necessary and implement their
own app chooser for each file and protocol type.<br>
<div> <br>
Firefox and Midori gave me a useless error page when I tried
clicking on an unrecognized protocol URL. I noticed Chromium gave
me this though:<br>
<br>
<img src="cid:part1.03010606.06070502@gmail.com" alt=""><br>
<br>
xdg-open? I assume that is a freedesktop query for Gnome, and not
part of a DE-wide standard?<br>
<br>
<br>
<br>
<br>
<br>
On 09/29/2012 02:29 PM, Jerome Leclanche wrote:<br>
</div>
<blockquote type="cite">
<blockquote type="cite">A protocol has a mime type:
x-scheme-handler/<protocol>. To associate with http, you
need to associate with the mime type x-scheme-handler/http.
<div><br>
</div>
<div>It is up to the implementation to detect the mime type out
of that protocol (eg. image/png out of <a href="http://example.com/foo.png" target="_blank">http://example.com/foo.png</a>),
but on a practical level, <a>file://</a> is
special-cased to detect the mime type, and the rest is usually
left to DEs with things like KIO and such. Correct me if I'm
wrong on this one.<br>
<div><br clear="all">
J. Leclanche<br>
<br>
<br>
<div class="gmail_quote">On Sat, Sep 29, 2012 at 8:22 PM,
Yfrwlf <span dir="ltr"><<a href="mailto:yfrwlf@gmail.com" target="_blank">yfrwlf@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> The association
of applications to file types and URLs are handled in
different ways by different desktop environments (DEs)
currently. It is understandable as to how this system
evolved, because you want <a>file://</a>
to be associated with Dolphin in KDE, and with
Nautilus in Gnome. However, this leaves programs
broken which try to register with specific DEs which
the user doesn't use. Developers are not able to
work with every DE's proprietary registration system
because doing so is impossible. This helps create a
detrimental environment for the open source
ecosystem. There should be standards for setting
default applications for file and URL handlers if none
currently exist, and they need to address the issue of
DE-specific needs as well as default settings for all
DEs.<br>
<br>
Does anyone know if such standards exist yet? If not,
we need to create them. Here is an example of the
logic that could be used. The first two columns
specify what application is the <b>default/primary</b>
application to run when the user calls a certain file
or URL type, and the 3rd column gives the
corresponding action that should be used to decide
which one to run.<br>
<br>
<table border="1" cellpadding="2" cellspacing="2" width="100%">
<tbody>
<tr>
<td bgcolor="#ffcccc">DE-Wide</td>
<td bgcolor="#ffcccc" valign="top">DE-Specific<br>
</td>
<td bgcolor="#ffcccc" valign="top">Resulting
Selection while running Specific DE<br>
</td>
<td bgcolor="#ffcccc" valign="top">Action upon
installing<br>
</td>
</tr>
<tr>
<td valign="top">none specified<br>
</td>
<td valign="top">none specified</td>
<td valign="top">prompt user for program or do
nothing<br>
</td>
<td valign="top">Change both DE-Wide and
DE-Specific<br>
</td>
</tr>
<tr>
<td valign="top">nautilus<br>
</td>
<td valign="top">none specified</td>
<td valign="top">run nautilus<br>
</td>
<td valign="top">Change only DE-Specific<br>
</td>
</tr>
<tr>
<td valign="top">none specified</td>
<td valign="top">nautilus<br>
</td>
<td valign="top">run nautilus<br>
</td>
<td valign="top">Could prompt user, change
DE-Wide<br>
</td>
</tr>
<tr>
<td valign="top">nautilus<br>
</td>
<td valign="top">dolphin<br>
</td>
<td valign="top">run dolphin<br>
</td>
<td valign="top">Could prompt user<br>
</td>
</tr>
</tbody>
</table>
<br>
<br>
The "Action upon installing" column refers to when a
program is being installed or run for the first time
and attempts update the association. If a program
finds an existing setting, it could either ask the
user if they want to change it or make the change
anyway or do nothing. In turn, that choice could,
ideally, depend on a DE or global setting as well so
that users could avoid all prompts like that in order
to further create a uniform desktop experience.
Regardless, the installer/program would always at
least add itself to a list of applications which can
be used to handle that file type or URL, so there
would be a default app setting and a path to that app
as well as a list of all apps capable of handling the
request.<br>
<br>
Examples:<br>
When installing applications such as torrent clients,
they should register <a>"magnet://"</a>
to call them, no matter the DE.<br>
When installing web browsers, "url://" should be
associated to them, no matter the DE.<br>
When installing a chat client, programs should
register themselves for each "aim://", "yahoo://",
"xmpp://" etc URL type, and possibly prompt user for
changing the defaults for those if one already exists.<br>
<br>
Implementation:<br>
What would be the best way to implement this
standard? What existing standards are being used for
these types of things, if any? I know that Gnome has
gconf and has what amounts to basically a registry for
Gnome, but the problem is that it is just for Gnome
and so not a true standard that all DEs and programs
can use. Perhaps if Gnome's registry is done well, a
similar system could be placed in ~/.config, which
seems to be the standard for all user configuration
data which many apps are currently choosing to use.<br>
<br>
Thoughts, ideas, and suggestions please!<br>
</div>
<br>
_______________________________________________<br>
xdg mailing list<br>
<a href="mailto:xdg@lists.freedesktop.org" target="_blank">xdg@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/xdg" target="_blank">http://lists.freedesktop.org/mailman/listinfo/xdg</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
<br>
</blockquote>
<br>
</div>
</div></div></blockquote></div><br></div>