[Lazarus] Open URL in "default" browser X-platform

ik idokan at gmail.com
Thu Dec 4 08:44:42 CET 2008

On Linux you can use the alternatives to decide what browser to open.
On debian (I don't know about non debian based distro) you can use the
sensible-browser command.
It points to the default web browser.



On Thu, Dec 4, 2008 at 12:54 AM, Bart <bartjunk64 at gmail.com> wrote:

> Hi,
> I come from Windows/Delphi (3.0) background and I'm gradually moving
> towards Lazarus/fpc.
> Opening an URL in Windows is a piece of cake, you just let the OS take
> care of the assotiations with the http protocol to open it (using
> shellexecute).
> This of course will not do for other platforms.
> So I set myself the task of launching an URL in an external browser on
> other platforms.
> Since I only have Linux (besides Win) I began with that.
> I tried to find examples on the net, but had no luck.
> I might well be re-inventing the wheel though...
> Here's my approach:
> - try to detect the windowmanger (for now I know how to do this for
> KDE and GNOME, XFCE is on my whishlist)
> On KDE
> - lookup DESKTOK_LAUNCH environment variable
> - if not there, look for kde-open
> - if not there look for kfmclient
> - if not there look for xdg-open
> - if not there try fallback
> (possibly using gnome-open might also work under KDE ???)
> - look fo gnome-open
> - if not there, look for xdg-open
> - if not there try fallback
> Fallback
> - search for know browsers (firefox, iceweasel, mozilla, opera,
> konqueror, ...(suggestions are welcome))
> If browser (or URL handler like kde-open, xdg-open etc.) is found
> launch it with the appropriate URL.
> This approach (the finding mechanism) seems to work at least on my
> Suse KDE desktop.
> I would like your opinions on this approach, and better still, I would
> like some suggestions how to achieve something similar on a Mac.
> (I suppose on Mac OSX the linux approach should work also???)
> And as a final rather dumb question: do all supported OS's have an
> environmentvariable PATH (as this is used in the fallback mechanism)?
> Bart
> _______________________________________________
> Lazarus mailing list
> Lazarus at lazarus.freepascal.org
> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20081204/90d23c55/attachment-0007.html>

More information about the Lazarus mailing list