Comments (2)
The opener
crate delegates to xdg-open
on Linux. Not sure what I can do here.
from opener.
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)
- please include LICENSE files into the repo and all crates HOT 3
- opener::OpenError should implement std::error::Error
- Browser not opening on Linux HOT 13
- On macOS, `opener` uses Safari where as the `open` command uses Firefox HOT 2
- Browser doesn't open on WSL2 HOT 2
- 0.4 doesn't seem to use either BROWSER or the default-browser from XDG. HOT 2
- Open in named tab for URL HOT 1
- Not enough context in error messages HOT 1
- Switch the backend on Linux (and WSL) from xdg-open to handlr
- published crates don't contain license texts but only contain bogus symlink HOT 2
- Reveal file in file explorer HOT 1
- Opening links doesn't work on WSL when using wslview
- URL opened as file path in WSL2 HOT 4
- Support WSL without requiring `wslview` or `xdg-open` HOT 5
- docs.rs failed to build docs HOT 1
- `opener::open` does not fail at all, even when e.g. file is missing on Linux HOT 5
- Android support?
- "Reveal" feature causes the app to segfault on linux in some cases HOT 11
- How to open a folder on windows and focus it? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opener.