KIO in Python doesn't appear to cope with some custom URI schemas

The advised way to invoke a non-standard URI schema in Python is to utilize webbrowser.open("schema://"): [1]

#!/usr/bin/env python3.13
import webbrowser  
webbrowser.open("steam://")

However, KIO doesn’t appear to cope with this:

Does anyone know of an alternative method that I can use to ensure that this is just an issue with webbrowser, rather than KIO?

You can test it with applications:/ too, if you’ve not Steam installed.


  1. stackoverflow.com/revisions/13214728/1 ↩︎

It doesn’t work with Qt’s method, either:

#!/usr/bin/env python3.13
import \
    PyQt6.QtWidgets, \
    PyQt6.QtCore, \
    PyQt6.QtGui

PyQt6.QtGui.QDesktopServices.openUrl(
    PyQt6.QtCore.QUrl("steam://")
)

I’ll presume it’s KIO, and just call xdg-open instead.

stackoverflow.com/revisions/57167056/1 (.connect(lambda: ) and some refactoring worked for invoking applications:// in dolphin, but not steam://. Perplexing.

Examples

#!/usr/bin/env python3.13

import \
    builtins, \
    PyQt6.QtWidgets, \
    PyQt6.QtCore, \
    PyQt6.QtGui

FREEDESKTOP_APPLICATIONS: builtins.str = "applications:/"

class ApplicationMenu:
    """
    Application Menu (Class)
    ------------------------
    Provides:
    1. [-] A `QMainWindow` to manipulate application entries and their categories.
    2. [ ] A `QMenu` for quick invocation thereof, when manipulation is unnecessary.
    """

    def invoke_uniform_resource_identifier(
        uniform_resource_identifier: builtins.str | None = None
    ) -> None:
        """
        Invokes a URI.
        """
        PyQt6.QtGui.QDesktopServices.openUrl(
            PyQt6.QtCore.QUrl(
                uniform_resource_identifier
            )
        )
tree_widget.itemDoubleClicked.connect(
    lambda: ApplicationMenu.invoke_uniform_resource_identifier(
        uniform_resource_identifier=FREEDESKTOP_APPLICATIONS
    )
)