authenticator: Use g_app_info_launch_default_for_uri() to launch browser

This way we get the system default. We still respect BROWSER if set
which is useful for e.g. the tests or scripts.
This commit is contained in:
Alexander Larsson
2019-12-12 14:07:33 +01:00
committed by Alexander Larsson
parent 4902acbebf
commit e08cee0e82

View File

@@ -521,18 +521,25 @@ webflow_start (FlatpakTransaction *transaction,
return FALSE;
}
/* Allow hard overrides with $BROWSER */
browser = g_getenv ("BROWSER");
if (browser == NULL)
browser = "xdg-open";
/* TODO: Use better way to find default browser */
args[0] = browser;
if (!g_spawn_async (NULL, (char **)args, NULL, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, &local_error))
if (browser != NULL)
{
g_printerr ("Failed to spawn browser %s: %s\n", browser, local_error->message);
return FALSE;
args[0] = browser;
if (!g_spawn_async (NULL, (char **)args, NULL, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, &local_error))
{
g_printerr ("Failed to start browser %s: %s\n", browser, local_error->message);
return FALSE;
}
}
else
{
if (!g_app_info_launch_default_for_uri (url, NULL, &local_error))
{
g_printerr ("Failed to show url: %s\n", local_error->message);
return FALSE;
}
}
g_print ("Waiting for browser...\n");