35
submitted 3 weeks ago* (last edited 3 weeks ago) by tinkralge@programming.dev to c/linux@programming.dev

Before I go off an write something myself, many things we open from our apps are HTTP/S URLs and they go straight to the browser. On Android, it's possible to assign apps to certain domains. I know I could write a script to do the same in linux, but my question is if there is a solution that already does this.

For those who don't know how, here's a superuser page that explains how to handle custom protocols.

This is what I use for now to open videos directly in mpv instead of a browser

~/bin/open-http.sh

#!/usr/bin/env bash
set -eu
# install with `xdg-mime default http-handler.desktop x-scheme-handler/http`
#              `xdg-mime default http-handler.desktop x-scheme-handler/https`
# is https and supported by yt-dlp
if [[ "$1" == "https://"* ]] && yt-dlp --simulate "$1" ; then
    exec mpv "$1"
else
    librewolf "$1" 
fi

http-handler.desktop

[Desktop Entry]
Comment=
Exec=~/bin/open-http.sh %u
MimeType=x-scheme-handler/https;
Name=HTTP Scheme Handler
NoDisplay=false
Path=
PrefersNonDefaultGPU=false
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=

A GUI or just config file would be great.

top 8 comments
sorted by: hot top new old
[-] mote@lemmy.ca 22 points 3 weeks ago

You're not going to like this answer - there's a bunch of different ways depending on the app(s) and the desktop environment. The Arch wiki goes over it in detail: https://wiki.archlinux.org/title/Default_applications

I would guess that focusing on the XDG spec and covering Gnome, KDE and Xfce (Xfce can be replaced with anything else like Cinnamon that comes with Mint, "non Gnome or KDE") is the best plan of attack for what matters to 80%+ of the population.

[-] mote@lemmy.ca 7 points 3 weeks ago

The above said, it wasn't hard to find a project using XDG and a JSON mapping file (basically your idea fleshed out in python) to get where you want to go if XDG is enough: https://github.com/JonTheNiceGuy/usbrowser

[-] lemmysmash@piefed.social 5 points 3 weeks ago

A side-question: isn't yt-dlp --simulate pretty slow? Especially given the fact that mpv would need to do the same thing again. Wouldn't having just a regexp that matches most of the yt-dlp-supported video URLs be much more efficient?

[-] hirihit640@sh.itjust.works 3 points 3 weeks ago

A quick search on flathub led me to https://flathub.org/en/apps/io.github.alyraffauf.Switchyard

There might be better ones, this was just the first I saw that stood out

[-] possiblylinux127@lemmy.zip 1 points 3 weeks ago* (last edited 3 weeks ago)

You can change the default apps in the default apps menu

To test you can run XDG-open on a URL or file

[-] davidgro@lemmy.world 1 points 3 weeks ago

The important part (which is missing by default) is opening different apps for different domains in the same scheme (such as https)

[-] ISO@lemmy.zip 1 points 3 weeks ago

Surprised no one mentioned the BROWSER environment variable.

Not everyone use xdg crap.

[-] racketlauncher831@lemmy.ml 1 points 3 weeks ago

I just love how your comment and the other one which stresses the importance if XDG spec. It's a free society. Keep your XDG crap to your place until I say otherwise.

this post was submitted on 18 Aug 2026
35 points (100.0% liked)

Linux

14929 readers
251 users here now

A community for everything relating to the GNU/Linux operating system (except the memes!)

Also, check out:

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 3 years ago
MODERATORS