+static int get_default_browser(void) {
+ struct swb_config cfg;
+ int i;
+
+ swb_config_init(&cfg);
+
+ if (!swb_config_load(&cfg))
+ return 1;
+
+ /* Check to see if the configured default browser is installed
+ If not, report the default default browser */
+ for (i = 0; browsers[i].config; ++i) {
+ if (strcmp(browsers[i].config, cfg.default_browser))
+ continue;
+
+ if (browsers[i].binary && access(browsers[i].binary, X_OK))
+ printf("%s\n", browsers[0].config);
+ else
+ printf("%s\n", browsers[i].config);
+
+ break;
+ }
+
+ if (!browsers[i].config)
+ /* Unknown browser configured as default, report the default
+ default browser */
+ printf("%s\n", browsers[0].config);
+
+ swb_config_free(&cfg);
+
+ return 0;
+}
+