Coder Social home page Coder Social logo

Comments (2)

Seeker14491 avatar Seeker14491 commented on August 16, 2024

The opener crate delegates to xdg-open on Linux. Not sure what I can do here.

from opener.

matta avatar matta commented on August 16, 2024

I was running into this same issue.

On my system, xdg-open is configured to run the flatpak version of Firefox. I suspect that whatever logic is doing this is taking the one html file passed on the command line and sandboxing it into a temporary directory, then passing that to Firefox. I don't know if this is a bug or a WAI from the point of view of flatpak.

I also found https://wiki.debian.org/DefaultWebBrowser#Opening_the_default_browser_from_a_script. So, at least on Debian systems, it is most "sensible" to open a browser with sensible-browser instead of xdg-open. On my system, sensible-browser ends up running gnome-www-browser, which also works when run directly.

pprof, a program run by Google, does something completely different that has always worked for me (but hard codes a preference for Chrome...): https://github.com/google/pprof/blob/f7f687d19a9829062f02a2dd6e9a6fb527dbf143/internal/driver/commands.go#L354

So, my workaround is running commands like gnome-www-browser target/doc/whatever/index.html directory.

The current contens of the sensible-browser script, on a Debian 12 system, is this:

#!/bin/sh

# Prevent recursive loops, where these values are set to this script
p="$(command -v "$0")"
[ -n "$BROWSER" ] && [ "$(command -v "$BROWSER" || true)" = "$p" ] && BROWSER=

IsError()
{
	# Operating system command not found
	[ "$1" -ne 126 ] && [ $1 -ne 127 ]
}

Run()
{
	"$@"
	ret=$?
	IsError "$ret"
}

if test -n "$BROWSER"; then
    Run "${BROWSER}" "$@" && exit "$ret"
fi

if test -n "$DISPLAY"; then
    if test -n "$GNOME_DESKTOP_SESSION_ID"; then
        if test -x /usr/bin/gnome-www-browser; then
            exec /usr/bin/gnome-www-browser "$@"
        elif test -x /usr/bin/x-www-browser; then
            exec /usr/bin/x-www-browser "$@"
        elif test -x /usr/bin/gnome-terminal && test -x /usr/bin/www-browser; then
            exec /usr/bin/gnome-terminal -x /usr/bin/www-browser "$@"
        fi
    fi
    if test -x /usr/bin/x-www-browser; then
        exec /usr/bin/x-www-browser "$@"
    elif test -x /usr/bin/x-terminal-emulator && test -x /usr/bin/www-browser; then
        exec /usr/bin/x-terminal-emulator -x /usr/bin/www-browser "$@"
    fi
elif test -x /usr/bin/www-browser; then
    exec /usr/bin/www-browser "$@"
fi

echo "Couldn't find a suitable web browser!\n" >&2
echo "Set the BROWSER environment variable to your desired browser.\n" >&2
exit 1;

from opener.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.