-
Pl
chevron_right
Ignacy Kuchciński: Flatpak STF: Terminal Intent
news.movim.eu / PlanetGnome • 10 hours ago • 4 minutes
I’ve been working for a while as a contractor as part of the Sovereign Tech Fund (STF) initiative for Flatpak, organized by Modal and Para-Real Ltd. There is a nice write up about the project, giving an overview of the investment and the collaborative effort.
Intents
My involvement has been focused on the Intents, which is an abstract system for apps to declare their offered services. Applications can announce which Intents they support using the Implements key from the Desktop Entry specification, and the default selection mechanism is solved by the intent-apps specification. For example, one could develop a Thumbnailer Intent, which would be then supported by implementing a specific DBus interface (e.g. “org.freedesktop.Thumbnailer1”). That would allow for apps and system components to have a standardized, flatpak friendly way to discover thumbnailers, and use their functionality in the sandboxed world, increasing security. Another use case would be an URI Handler Intent, that would among others let users specify which applications they would like to be opened when clicking a particular link. The overall idea has been going for quite a while, and there are some very good sources to read up on the Intents in general, including Andy Holmes’ “Best Intentions” blog post and Sebastian Wick’s follow up.
Terminal Intent
Last year the intent-apps specification allowing for default selection of Intents was accepted, and the next step is to start implementing them. One that caught interest is the Terminal Intent. Currently, there is no standardized, sandbox friendly way for the system to discover terminal emulators, and use their functionality. It’s not associated with either a mime-type or an URI scheme, which is one of the reasons why changing the default terminal has been challenging for a long time now.
This changes with the proposed spec, that allows applications to implement the “org.freedesktop.Terminal1” Intent, and therefore advertise to the system and other interested users that it’s a terminal emulator, capable of executing commands via a specific D-Bus interface. In GNOME, it will unlock many things we’ve wanted for quite a while, among others: changing the default terminal in Settings, adjusting the behaviour when launching apps meant for terminal, and opening directories from the file manager.
Settings
There’s an early implementation in GNOME Settings for the terminal Intent, that exposes an option to change the default terminal emulator across the system. Applications that are meant to be executed in a terminal window, which is indicated by a “Terminal=true” line in their desktop file, would then launch in the previously selected terminal. Apart from the spec being accepted itself, for the functionality to work correctly, there needs to be support for the intent in GLib, which is being worked on, as well as in the terminal emulators themselves, with both Console and Ptyxis having work in progress implementations.
Settings with an option to choose the default terminal
Below I’ve provided screen recordings of Shell launching Vim in a terminal emulator chosen in Settings, as well as a custom terminal application.
Files
Another cool use case would be opening directories from the file manager in the terminal, adhering to the selected default in Settings. The integration would also cover other terminal related functionality, such as running the scripts as programs in the terminal. There’s a work in progress implementation in GNOME Files.
Here’s another pair of screen recordings, showing Files opening directories and running a custom script in a terminal emulator chosen in Settings.
Testing
As usual, I’ve prepared a custom GNOME OS image that can be used to test the functionality, which I’ve also used to make various screenshots and recordings in this blog post. You’ll need to install it (in GNOME Boxes for example), which takes a simple click and does not require a reboot (magic!). To be able to switch between different default terminals, you’ll want to download the custom build of Ptyxis as well, and install it with a command “flatpak install ptyxis-terminal-intent.flatpak”. Then you can get some applications meant for terminal such as Vim directly in Software, which is preconfigured to get them from Flathub.
Next
Currently, the major blocker for the work is getting the Terminal Intent specification accepted upstream, which needs to be merged before the rest of the ecosystem can fully embrace it. There needs to be consensus from other desktops such as KDE, after which the focus would become the GLib integration, following support from individual applications. And in the future, work on other Intents can begin, unlocking many more possibilities.
I’d like to thank Modal and Para-Real Ltd. for the ability to work on this, as well as Sovereign Tech Agency for sponsoring the work. I also really appreciate the help from the technical leads Sebastian Wick and Adrian Vovk who are always there to answer questions, the organization of the work by Kateryna Omeltschenko who knows how to brighten up a meeting, and Cade Diehm, who’s bravely fighting with the bureaucracy for us.
Until the next update!