Have you ever thought "How can I install Flathub apps without all the hassle? I hate Gnome Software, searching for flatpaks in the terminal is a nightmare (app ids), and what even is the .flatpakref file???"
I have the solution for you.
Note: I haven't studied appstream: URIs a lot so this may be (really) buggy when not using flathub
- Get flatline
- Install
~/.local/share/applications/AppStreamDirectFlatpakInstall.desktop
(note: modify thehandler.py
path later)
[Desktop Entry]
Type=Application
Name=AppStream Direct Flatpak Install
Exec=/PATH/TO/YOUR/handler.py %u
StartupNotify=false
MimeType=x-scheme-handler/appstream;
- Install
handler.py
(note: replaceYOURTERMINAL
- for example the new Gnome Console iskgx
)
#!/usr/bin/env python3
import subprocess
from urllib.parse import urlparse
import sys
TERMINAL = ["YOURTERMINAL", "-e", "flatpak install "]
uri = sys.argv[1]
o = urlparse(uri)
if o.scheme != "appstream":
sys.exit(1)
appid = o.path or o.netloc
TERMINAL[-1] += appid
subprocess.Popen(TERMINAL)
-
Make the file executable (
chmod +x handler.py
) and replace the path in step 2 -
Finally, set the handler for
appstream:
URIs
xdg-mime default ~/.local/share/applications/AppStreamDirectFlatpakInstall.desktop x-scheme-handler/appstream
- Test it out by going to https://flathub.org or https://beta.flathub.org