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!
저자 소개
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).
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
오리지널 쇼
엔터프라이즈 기술 분야의 제작자와 리더가 전하는 흥미로운 스토리