Invoking the default browser in Linux.

Just starting out? Need help? Post your questions and find answers here.
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Invoking the default browser in Linux.

Post by heartbone »

I see this subject has been visited before for Windows and OSX:
[Windows] GetDefaultBrowser() http://www.purebasic.fr/english/viewtop ... 12&t=40093
[OSX] Launch a webpage? http://www.purebasic.fr/english/viewtop ... 19&t=52282

Now it's [Linux]'s turn.
Based on searching this forum, the best ways that I know of to start the browser to access a specific web follows.
Windows: RunProgram("http://www.purebasic.com/")
RunProgram("rundll32.exe","url.dll,FileProtocolHandler "+#DQUOTE$+"http://google.com"+#DQUOTE$,"")
ShellExecute_(0,"open","http://www.google.com","","",1)

OSX: RunProgram("open","http://www.purebasic.com/","")

The man page for Firefox leads me to this solution.
Linux: RunProgram("/usr/lib/firefox/firefox","-new-window http://www.purebasic.com/","")

The PureBasic command shown above works fine for my UBUNTU installation,
but I doubt if that path or browser is default for every Linux user.
I have used ExamineEnvironmentVariables() and I did not see any mention of browser there.

Does anyone know a way to invoke the default browser from PureBasic in Linux?
Keep it BASIC.
Totusoft
User
User
Posts: 15
Joined: Tue Feb 12, 2013 4:00 pm
Location: Minnesota, USA
Contact:

Re: Invoking the default browser in Linux.

Post by Totusoft »

I use

RunProgram("xdg-open","http://www.purebasic.com","")

-Pete
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: Invoking the default browser in Linux.

Post by heartbone »

Totusoft wrote:I use

RunProgram("xdg-open","http://www.purebasic.com","")

-Pete
It works like a charm.
I thank you very much kind sir. :D
Keep it BASIC.
Post Reply