From 7515bc1dd374c706871368ed585eb9794fa3fc4f Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 21 Jul 2017 15:29:07 +0200 Subject: my_distro_help(): Be less Debian-centric and detect other browser, if x-www-browser does not exist. --- src/backend-dbus/actions.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'src/backend-dbus') diff --git a/src/backend-dbus/actions.c b/src/backend-dbus/actions.c index 1836d94..9169b5d 100644 --- a/src/backend-dbus/actions.c +++ b/src/backend-dbus/actions.c @@ -922,10 +922,47 @@ my_desktop_help (IndicatorSessionActions * self G_GNUC_UNUSED) run_outside_app ("yelp"); } +static char * +find_browser () +{ + static char * browser_path = NULL; + char* tmp_browser_path; + gchar **browser_names; + + int i; + + if (browser_path == NULL) + { + + browser_names = g_strsplit ("x-www-browser,google-chrome,firefox,chromium", ",", 0); + + for (i = 0; browser_names[i]; ++i) { + + tmp_browser_path = g_find_program_in_path (browser_names[i]); + + if (tmp_browser_path) { + browser_path = g_strdup (tmp_browser_path); + g_free (tmp_browser_path); + g_strfreev (browser_names); + break; + } + } + } + + return browser_path; + +} + static void my_distro_help (IndicatorSessionActions * self G_GNUC_UNUSED) { - run_outside_app(g_strdup_printf("x-www-browser '%s'", get_distro_url())); + static char * browser = NULL; + + if (browser == NULL) + browser = find_browser(); + + if (browser != NULL) + run_outside_app(g_strdup_printf("%s '%s'", browser, get_distro_url())); } -- cgit v1.2.3