If you’re like me, you probably like to launch your GUI applications from the terminal at least occasionally… or from scripts… or from a quick launcher which doesn’t search .desktop
names because you find it annoying to have your intent second-guessed by poor ergonomics in “multiple things match” situations.
However, as shown by the Flatpak developers closing #1188: Improve cli application experience and then locking it because real-world reports of how awkward the current situation is (eg. for invoking a Flatpak-installed copy of Meld from git merge
) are apparently “abusive comments”, /var/lib/flatpak/exports/bin
is the best we’ll get out of them, and I don’t like typing org.inkscape.Inkscape
in the terminal.
I still think Flatpak is the best solution for a lot of other things which I don’t want to have to do myself (especially when paired with using Flatseal to lock down app permissions further), but this is ugly, it’s a usability regression, and it doesn’t even tab-complete well.
Fortunately, since I’m an end-user who doesn’t have to solve all the edge-cases, it’s easy for me to hack together a solution that works in all my use-cases.
Just…
- Query Flatpak for the list of installed application IDs (
flatpak list --columns=ref
) - Run
flatpak info -m
on each application ID and parse out the application’s actual command name (if one exists) from the.ini
-esque output (not perfect, since some app developers/maintainers will use/omit launcher wrappers when they don’t expect you to have to type the name, but it gets you 99% of the way. For example, Flatseal‘s actual binary name iscom.github.tchx84.Flatseal
, notflatseal
, and Flatpak is a perfect way to distrust something like JDownloader that you still need to use, but itscommand
isjd-wrapper
.) - Add a folder to the end of your
PATH
containingexec flatpak run ... "$@"
scripts named after the extracted command names. (Better than usingalias
because you don’t have to coordinate re-source
-ing the file in each open terminal for updates to apply.)
…and so, I present to you a proof of concept. It’s got shortcomings, but those are all fixable when I have time to come back to it and rewrite it in a language with a proper .ini
parser:
Nicer Terminal Commands For Flatpak-Installed Applications by Stephan Sokolow is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution under the same terms as the associated post.
All comments are moderated. If your comment is generic enough to apply to any post, it will be assumed to be spam. Borderline comments will have their URL field erased before being approved.