8go / matrix-commander

simple but convenient CLI-based Matrix client app for sending and receiving
GNU General Public License v3.0
563 stars 59 forks source link

Bug: SSO login browser launch broken on some distros #115

Closed weeksco closed 1 year ago

weeksco commented 1 year ago

Great tool, just one small issue for me on first run:

SSO login fails with "E231: Browser could not be launched" on Manjaro Sway because x-www-browser does not exist.

I could work around this with a symlink in my path e.g. "ln -s /usr/bin/chromium .local/bin/x-www-browser"

Maybe xdg-open could be used instead?

Thanks and keep up the great work

8go commented 1 year ago

Current code is:

            # launch web-browser
            if sys.platform.startswith("darwin"):
                cmd = [shutil.which("open")]
            elif sys.platform.startswith("win"):
                cmd = ["start"]
            else:
                cmd = [shutil.which("x-www-browser")]

Changing that to

            # launch web-browser
            if sys.platform.startswith("darwin"):
                cmd = [shutil.which("open")]
            elif sys.platform.startswith("win"):
                cmd = ["start"]
            else:
                cmd = [shutil.which("xdg-open")]

Would that fix it everywhere? Would that break it on different Linux distributions?

Ok, finally I decided to do the following:

            # launch web-browser
            if sys.platform.startswith("darwin"):
                cmd = [shutil.which("open")]
            elif sys.platform.startswith("win"):
                cmd = ["start"]
            else:
                cmd = [shutil.which("xdg-open")]
                if cmd == [None]:
                    cmd = [shutil.which("x-www-browser")]
8go commented 1 year ago

See new version, it tries xdg-open first, if that fails as fallback it tries x-www-browser.

@weeksco Please report back if that works for you now.

weeksco commented 1 year ago

Perfect! Many thanks