xdg-open opens a file or URL in the user's preferred application. If a
URL is provided the URL will be opened
in the user's preferred web browser.
If a file is provided the file will be
opened in the preferred application
for files of that type. xdg-open
supports file, ftp, http and https
URLs.
xdg-open is part of xdg-utils package and it's already installed on Ubuntu 10.10.
I played around this a little.
There is a problem with gnome-open — it won't invoke the default web browser unless you specify a url.
That's a problem if you want to set up an icon or a shortcut that will always launch the browser that is set as default.
Other times you might need to set it as a parameter for some programs that require a link to a web browser and don't work well with gnome-open (e.g.: acroread).
You might solve this by using either x-www-browser or gnome-www-browser system links that you can set up through update-alternatives, but those are system wide settings, not user specific (and they are not synchronized with the values set through gnome-default-applications-properties.
All this can be solved by opening the sensible-browserexecutable (which is actually a script):
That will make sensible-browser always launch the user-specified default web browser.
(I found out that gnome-default-applications-properties changes some gconf keys according to the browser that is currently set. The default browser value can be obtained from any of these keys so I went for /desktop/gnome/url-handlers/http/command and used it to fill the $BROWSER variable (the value is stripped of the "%s" part). )
sensible-browser
is the command you're looking for.Or:
xdg-open <URL>
.Searching on Google I found the answer.
xdg-open is part of xdg-utils package and it's already installed on Ubuntu 10.10.
You can also use:
And it will open the URL in the default browser.
Just that you may find it useful. A fallback approach, and one liner.
Good reading for the no familiar with the logical operators https://www.howtogeek.com/269509/how-to-run-two-or-more-terminal-commands-at-once-in-linux/.
and
With default Ubuntu setup only gnome-open command comes to mind.
I played around this a little. There is a problem with
gnome-open
— it won't invoke the default web browser unless you specify a url. That's a problem if you want to set up an icon or a shortcut that will always launch the browser that is set as default. Other times you might need to set it as a parameter for some programs that require a link to a web browser and don't work well withgnome-open
(e.g.:acroread
). You might solve this by using eitherx-www-browser
orgnome-www-browser
system links that you can set up throughupdate-alternatives
, but those are system wide settings, not user specific (and they are not synchronized with the values set throughgnome-default-applications-properties
. All this can be solved by opening thesensible-browser
executable (which is actually a script):and adding this at the beginning:
That will make
sensible-browser
always launch the user-specified default web browser. (I found out thatgnome-default-applications-properties
changes some gconf keys according to the browser that is currently set. The default browser value can be obtained from any of these keys so I went for/desktop/gnome/url-handlers/http/command
and used it to fill the$BROWSER
variable (the value is stripped of the"%s"
part). )On Raspberry Pi Ubuntu I did this to start a webpage, fullscreen (in Kiosk mode) on startup: