XDG Intents Updates
Andy Holmes wrote an excellent overview of XDG Intents in his “Best Intentions” blog post, covering the foundational concepts and early proposals. Unfortunately, due to GNOME Foundation issues, this work never fully materialized. As I have been running into more and more cases where this would provide a useful primitive for other features, I tried to continue the work.
The specifications have evolved as I worked on implementing them in glib, desktop-file-utils and ptyxis. Here’s what’s changed:
Intent-Apps Specification
Andy showed this hypothetical syntax for scoped preferences:
[Default Applications]
org.freedesktop.Thumbnailer=org.gimp.GIMP
org.freedesktop.Thumbnailer[image/svg+xml]=org.gnome.Loupe;org.gimp.GIMP
We now use separate groups instead:
[Default Applications]
org.freedesktop.Thumbnailer=org.gimp.GIMP
[org.freedesktop.Thumbnailer]
image/svg+xml=org.gnome.Loupe;org.gimp.GIMP
This approach creates a dedicated group for each intent, with keys representing the scopes. This way, we do not have to abuse the square brackets which were meant for translatable keys and allow only very limited values.
The updated specification also adds support for intent.cache
files to improve performance, containing up-to-date lists of applications supporting particular intents and scopes. This is very similar to the already existing cache for MIME types. The update-desktop-database
tool is responsible for keeping the cache up-to-date.
This is implemented in glib!4797, desktop-file-utils!27, and the updated specification is in xdg-specs!106.
Terminal Intent Specification
While Andy mentioned the terminal intent as a use case, Zander Brown tried to upstream the intent in xdg-specs!46 multiple years ago. However, because it depended on the intent-apps specification, it unfortunately never went anywhere. With the fleshed-out version of the intent-apps specification, and an implementation in glib, I was able to implement the terminal-intent specification in glib as well. With some help from Christian, we also added support for the intent in the ptyxis terminal.
This revealed some shortcomings in the proposed D-Bus interface. In particular, when a desktop file gets activated with multiple URIs, and the Exec
line in the desktop entry only indicates support for a limited number of URIs, multiple commands need to be launched. To support opening those commands in a single window but in multiple tabs in the terminal emulator, for example, those multiple commands must be part of a single D-Bus method call. The resulting D-Bus interface looks like this:
<interface name="org.freedesktop.Terminal1">
<method name="LaunchCommand">
<arg type='aa{sv}' name='commands' direction='in' />
<arg type='ay' name='desktop_entry' direction='in' />
<arg type='a{sv}' name='options' direction='in' />
<arg type='a{sv}' name='platform_data' direction='in' />
</method>
</interface>
This is implemented in glib!4797, ptyxis!119 and the updated specification is in xdg-specs!107.
Deeplink Intent
Andy’s post discussed a generic “org.freedesktop.UriHandler” with this example:
[org.freedesktop.UriHandler]
Supports=wise.com;
Patterns=https://*.wise.com/link?urn=urn%3Awise%3Atransfers;
The updated specification introduces a specific org.freedesktop.handler.Deeplink1
intent where the scheme is implicitly http
or https
and the host comes from the scope (i.e., the Supports
part). The pattern matching is done on the path alone:
[org.freedesktop.handler.Deeplink1]
Supports=example.org;extensions.gnome.org
example.org=/login;/test/a?a
extensions.gnome.org=/extension/*/*/install;/extension/*/*/uninstall
This allows us to focus on deeplinking alone and allows the user to set the order of handlers for specific hosts.
In this example, the app would handle the URIs http://example.org/login
, http://example.org/test/aba
, http://extensions.gnome.org/extension/123456/BestExtension/install
and so on.
There is a draft implementation in glib!4833 and the specification is in xdg-specs!109.
Deeplinking Issues and Other Handlers
I am still unsure about the Deeplink1 intent. Does it make sense to allow schemes other than http
and https
? If yes, how should the priority of applications be determined when opening a URI? How complex does the pattern matching need to be?
Similarly, should we add an org.freedesktop.handler.Scheme1
intent? We currently abuse MIME handlers for this, so it seems like a good idea, but then we need to take backwards compatibility into account. Maybe we can modify update-desktop-database
to add entries from org.freedesktop.handler.Scheme1
to mimeapps.list
for that?
If we go down that route, is there a reason not to also do the same for MIME handlers and add an org.freedesktop.handler.Mime1
intent for that purpose with the same backwards compatibility mechanism?
Deeplinking to App Locations
While working on this, I noticed that we are not great at allowing linking to locations in our apps. For example, most email clients do not have a way to link to a specific email. Most calendars do not allow referencing a specific event. Some apps do support this. For example, Zotero allows linking to items in the app with URIs of the form zotero://select/items/0_USN95MJC
.
Maybe we can improve on this? If all our apps used a consistent scheme and queries (for example xdg-app-org.example.appid:/some/path/in/the/app?name=Example
), we could render those links differently and finally have a nice way to link to an email in our calendar.
This definitely needs more thought, but I do like the idea.
Security Considerations
Allowing apps to describe more thoroughly which URIs they can handle is great, but we also live in a world where security has to be taken into account. If an app wants to handle the URI https://bank.example.org
, we better be sure that this app actually is the correct banking app. This unfortunately is not a trivial issue, so I will leave it for the next time.
-
XDG Intents Updates
-
Integrating libdex with GDBus
-
Testing with Portals
-
Display Next Hackfest 2025
-
GNOME 49 Backlight Changes
-
Blender HDR and the reference white issue
-
Booting into Toolbox Containers
-
On the Usefulness of SO_PEERPIDFD
-
Fedora Silverblue Development Utils
-
Developing Gnome Shell on Fedora Silverblue
-
Setting up a personal server in 2023
Do you have a comment?
Toot at me on mastodon or send me a mail!