Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

linux

glib

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?

like image 891
mfisch Avatar asked Dec 20 '22 04:12

mfisch


2 Answers

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).

like image 55
nemequ Avatar answered Dec 29 '22 12:12

nemequ


If it is installed then xdg-open would work.

xdg-open http://www.stackoverflow.com
like image 37
Cory Klein Avatar answered Dec 29 '22 10:12

Cory Klein