qutebrowser: Make xdg-utils optional

Replace all hard-coded instances of using xdg-open with at least one
non-xdg alternative. Mostly falling back to either mimeo or a custom
open script.
This commit is contained in:
Marty Oehme 2025-03-19 21:28:56 +01:00
parent ff2ae79878
commit d69a0f40e1
Signed by: Marty
GPG key ID: 4E535BC19C61886E
5 changed files with 41 additions and 8 deletions

View file

@ -21,6 +21,7 @@
# continue surfing like normal, only that you can now also access
# any gemini pages as if they were part of the normal http protocol.
import shutil
import cgi
import html
import os
@ -379,7 +380,10 @@ def open_url(url: str, open_args: str) -> None:
with open(fifo, "w") as qfifo:
qfifo.write(f"open {open_args} {to_open}")
return
os.system(f"xdg-open {to_open}")
if shutil.which("mimeo"):
_ = os.system(f"mimeo {to_open}")
elif shutil.which("xdg-open"):
_ = os.system(f"xdg-open {to_open}")
if __name__ == "__main__":