All Aboard the D-Bus

All Aboard the D-Bus
Image by James ADL.

Some time ago I quietly published desktop_entry to pub.dev. I was interested in a general solution for handling deep links within Flutter apps running on any platform, and at the time app_links did not have Linux support - as per this issue.

My interest in this stemmed from a common scenario in contemporary multiplayer games:

As a player, I would like to join the lobby my friend has created so that we can play together.

On Linux desktop environments, there is an established mechanism for exchanging data between processes, the D-Bus. An application can utilise the D-Bus by registering with the operating system it is running on by the way of Desktop Entry (.desktop) and Service (.service) files. There are a number of command-line utilities developers can use to generate boilerplate code for a D-Bus object and validate their configuration, such as xdg-mime. These utilities are really helpful as you can't control how other applications respond to custom URI schemes. E.g. entering a URI candidate into a web browser may result in the browser treating your custom scheme URI like any old string, and redirect to search engine query results for that string.

If you're distributing Linux applications (e.g. via Snap, Steam or otherwise), your application code might not interact with the D-Bus directly at all. Instead, some other service that does so on your behalf, as the current integration steps for app_links now suggest!