Ubuntu 10.10 is based on GNOME. Thus, it would be nice to use g_app_info_launch_default_for_uri() .
Something like this should work.
#include <stdio.h> #include <gio/gio.h> int main(int argc, char *argv[]) { gboolean ret; GError *error = NULL; g_type_init(); ret = g_app_info_launch_default_for_uri("file:///etc/passwd", NULL, &error); if (ret) g_message("worked"); else g_message("nop: %s", error->message); return 0; }
BTW, xdg-open , a shell script, tries to determine the desktop environment and call a well-known helper, such as gvfs-open for GNOME, kde-open for KDE, or something else. gvfs-open ends with a call to g_app_info_launch_default_for_uri() .
source share