I support various multimedia applications, and earlier this year, I started recommending that my clients install many of them as Flatpaks. I did this mostly because the Flatpak releases of these applications were quicker at integrating support for media codecs than the packages available elsewhere, and that's an essential feature for content creators using the latest gear on set. The results have been uniformly successful, but for one snag: Launching a Flatpak from the terminal isn't always the easiest thing to do.
The issue is well documented, but in short, a Flatpak application's formal name is essentially a reverse domain name. However, there's no standard for details like capitalization or naming schemes. That can make it difficult to remember, and the command itself isn't exactly terse:
$ flatpak run io.atom.Atom
A name like io.atom.Atom
is relatively easy to remember (though not as easy as just atom
), but then there are names like org.gimp.GIMP
(easy to understand, but what gets capitalized and what doesn't?) or org.eclipse.Java
or fr.handbrake.ghb
. There's endless variety for very pragmatic reasons, but it's hard to commit them to memory as part of a command.
Bash scripting is a unique power that Linux provides its users, though, and it's with that power that I came up with a simple workaround to help my users easily launch a Flatpak from a terminal.
Meet Fuzzpak
This is actually a workaround for a workaround. I've already written a solution for Flatpak launching, which I call pakrat. It takes its inspiration from the alternative
command and implements Bash aliases for installing Flatpaks. However, it's a manual process, and I assumed at the time that the sysadmin would install the Flatpaks, create Bash aliases, and the users would never know the difference.
That was back before I fully appreciated the flexibility of Flatpak, especially since users could install Flatpaks to their own home directory. Allowing users to install their own applications is nice, but it seems strange to a user that they can't then launch the application they've installed from a terminal. My pakrat
solution would work for them, but it's an added step that many didn't seem to relish doing.
And so I wrote Fuzzpak, a script that does a "fuzzy" search on user-installed Flatpaks and launches the first one it finds containing the string provided. For example, to launch GIMP:
$ fuzzpak gimp
Ideally, you want to give Fuzzpak the proper application name you want to launch. For instance, to launch the video editor Kdenlive, you use fuzzpak kdenlive
rather than, say, fuzzpak kde
because the string kde
appears in all KDE apps, such as org.kde.digikam
, org.kde.krita
, org.kde.kblocks
, and so on. The same goes for GNOME projects or projects referencing GitLab or GitHub.
Set the Flatpak directory
By default, Fuzzpak looks at the user's home directory (~/.var/app
) for installed Flatpaks. You can use the --directory
option (-d
for short) to set an alternate location:
$ fuzzpak --directory /var/lib/flatpak/app krita
Examine the Fuzzpak script
The script is simple:
#!/usr/bin/env bash
#GPLv3
DIR=${DIR:-$HOME/.var/app}
CMD=${CMD:-flatpak run}
launch_app() {
find "${DIR}" -mindepth 1 -maxdepth 1 \
-type d -iname "*$1*" -printf '%f\n' \
| xargs $CMD
}
# parse opts
while [ True ]; do
if [ "$1" = "--help" -o "$1" = "-h" ]; then
echo " "
echo "$0 [OPTIONS]"
echo "--directory, -d Location of flatpaks (default: $HOME/.var/app"
echo " "
exit
elif [ "$1" = "--directory" -o "$1" = "-d" ]; then
DIR=$DIR
shift 2
else
break
fi
done
# main
launch_app "${1}"
It's actually just a single find
command that looks through the target directory for a matching string pattern and then launches the first one that it finds. The rest of the script just sets the location of the Flatpaks and parses options.
It's not sophisticated, and I can certainly imagine a Python or Go solution that finds all potential matches and gives weight to the final position in the Flatpak name when choosing what to launch. However, I've found that it's effective, and I've been using it happily for about three months without incident.
Install Fuzzpak
If you want to install the script locally:
- Copy and paste the script into a file called
fuzzpak
(or whatever you want the command to be). - Save the file into
~/.local/bin
. (That's a hidden directory, so show hidden files in your file manager, or save it using the terminal.) - Make the script executable:
$ chmod +x ~/.local/bin/fuzzpak
Otherwise, you can just place fuzzpak
somewhere on your user's path. Now you're ready to install Flatpaks with Fuzzpak. Enjoy!
About the author
Seth Kenlon is a Linux geek, open source enthusiast, free culture advocate, and tabletop gamer. Between gigs in the film industry and the tech industry (not necessarily exclusive of one another), he likes to design games and hack on code (also not necessarily exclusive of one another).
Browse by channel
Automation
The latest on IT automation for tech, teams, and environments
Artificial intelligence
Updates on the platforms that free customers to run AI workloads anywhere
Open hybrid cloud
Explore how we build a more flexible future with hybrid cloud
Security
The latest on how we reduce risks across environments and technologies
Edge computing
Updates on the platforms that simplify operations at the edge
Infrastructure
The latest on the world’s leading enterprise Linux platform
Applications
Inside our solutions to the toughest application challenges
Original shows
Entertaining stories from the makers and leaders in enterprise tech
Products
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Cloud services
- See all products
Tools
- Training and certification
- My account
- Customer support
- Developer resources
- Find a partner
- Red Hat Ecosystem Catalog
- Red Hat value calculator
- Documentation
Try, buy, & sell
Communicate
About Red Hat
We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.
Select a language
Red Hat legal and privacy links
- About Red Hat
- Jobs
- Events
- Locations
- Contact Red Hat
- Red Hat Blog
- Diversity, equity, and inclusion
- Cool Stuff Store
- Red Hat Summit