static gint exitcode = 0;
static guint remote_control = 0;
static gboolean being_replaced = FALSE;
+static gchar *config_file = NULL;
static void signal_handler(gint signal, gpointer data);
static void remove_args(gint *argc, gchar **argv, gint index, gint num);
config_startup(i);
/* parse/load user options */
- if (parse_load_rc(NULL, &doc, &node)) {
+ if (parse_load_rc(config_file, &doc, &node)) {
parse_tree(i, doc, node->xmlChildrenNode);
parse_close(doc);
- } else
+ }
+ else {
g_message(_("Unable to find a valid config file, using some simple defaults"));
+ config_file = NULL;
+ }
-/*
- if (config_type != NULL)
- PROP_SETS(RootWindow(ob_display, ob_screen),
- ob_config, config_type);
-*/
+ if (config_file) {
+ gchar *p = g_filename_to_utf8(config_file, -1,
+ NULL, NULL, NULL);
+ if (p)
+ PROP_SETS(RootWindow(ob_display, ob_screen),
+ ob_config_file, p);
+ g_free(p);
+ }
+ else
+ PROP_ERASE(RootWindow(ob_display, ob_screen),
+ ob_config_file);
/* we're done with parsing now, kill it */
parse_shutdown(i);
g_print(_(" --help Display this help and exit\n"));
g_print(_(" --version Display the version and exit\n"));
g_print(_(" --replace Replace the currently running window manager\n"));
+ g_print(_(" --config-file FILE Specify the path to the config file to use\n"));
g_print(_(" --sm-disable Disable connection to the session manager\n"));
g_print(_("\nPassing messages to a running Openbox instance:\n"));
g_print(_(" --reconfigure Reload Openbox's configuration\n"));
else if (!strcmp(argv[i], "--exit")) {
remote_control = 3;
}
+ else if (!strcmp(argv[i], "--config-file")) {
+ if (i == *argc - 1) /* no args left */
+ /* not translated cuz it's sekret */
+ g_printerr(_("--config-file requires an argument\n"));
+ else {
+ /* this will be in the current locale encoding, which is
+ what we want */
+ config_file = argv[i+1];
+ ++i; /* skip the argument */
+ ob_debug("--config-file %s\n", config_file);
+ }
+ }
else if (!strcmp(argv[i], "--sm-save-file")) {
if (i == *argc - 1) /* no args left */
/* not translated cuz it's sekret */
g_hash_table_insert(i->callbacks, c->tag, c);
}
-gboolean parse_load_rc(const gchar *type, xmlDocPtr *doc, xmlNodePtr *root)
+gboolean parse_load_rc(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root)
{
GSList *it;
gboolean r = FALSE;
- gchar *fname;
- if (type == NULL)
- fname = g_strdup("rc.xml");
- else
- fname = g_strdup_printf("rc-%s.xml", type);
+ if (file && parse_load(file, "openbox_config", doc, root))
+ return TRUE;
for (it = xdg_config_dir_paths; !r && it; it = g_slist_next(it)) {
gchar *path;
- path = g_build_filename(it->data, "openbox", fname, NULL);
+ path = g_build_filename(it->data, "openbox", "rc.xml", NULL);
r = parse_load(path, "openbox_config", doc, root);
g_free(path);
}
- g_free(fname);
return r;
}
void parse_shutdown(ObParseInst *inst);
/*! Loads Openbox's rc, from the normal paths
- @type The configuration type to load, or NULL to use the default.
- e.g. "gnome" would load rc-gnome.xml.
+ @param file The path of the config to try load. NULL to load from the
+ default path
*/
-gboolean parse_load_rc(const gchar *type, xmlDocPtr *doc, xmlNodePtr *root);
+gboolean parse_load_rc(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root);
/* Loads an Openbox menu, from the normal paths */
gboolean parse_load_menu(const gchar *file, xmlDocPtr *doc, xmlNodePtr *root);
/* Loads an Openbox theme, from the normal paths */