How can I programmatically open the default browser and pass a URL in C/Linux?
Asked Answered
C

2

5

Is there a convenient library call that allows me to open the default browser that I can use from C? I poked around in glib and didn't see anything. There is xdg-open, and I can just system that I guess. Any better ideas?

Cubbyhole answered 18/6, 2013 at 18:35 Comment(2)
I think xdg-open is the right approach, since you can just pass it directly a URL and it will pick the user's preferred browser.Wolverine
I ended up doing that because it was really simple. Thanks.Cubbyhole
X
5

If it is installed then xdg-open would work.

xdg-open http://www.stackoverflow.com
Xylophone answered 18/6, 2013 at 19:3 Comment(0)
B
8

Since you tagged this question with "glib", the right solution is probably to use g_app_info_launch_default_for_uri (or one of the other GAppInfo methods, depending on your exact use case).

Beyond answered 20/6, 2013 at 18:7 Comment(0)
X
5

If it is installed then xdg-open would work.

xdg-open http://www.stackoverflow.com
Xylophone answered 18/6, 2013 at 19:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.