all repos — openbox @ bbad88aa21f01a70faf824cbb2825bd7f9d95253

openbox fork - make it a bit more like ryudo

add a --config-file command line option, and OB_CONFIG_FILE root hint
Dana Jansens danakj@orodu.net
commit

bbad88aa21f01a70faf824cbb2825bd7f9d95253

parent

674c042c68602fbe19d525a697b35870b7029b41

6 files changed, 40 insertions(+), 18 deletions(-)

jump to
M openbox/openbox.copenbox/openbox.c

@@ -107,6 +107,7 @@ static KeyCode keys[OB_NUM_KEYS];

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);

@@ -246,17 +247,26 @@ /* start up config which sets up with the parser */

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);

@@ -489,6 +499,7 @@ g_print(_("\nOptions:\n"));

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"));

@@ -565,6 +576,18 @@ remote_control = 2;

} 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 */
M openbox/prop.copenbox/prop.c

@@ -172,6 +172,7 @@ */

CREATE(openbox_pid, "_OPENBOX_PID"); CREATE(ob_theme, "_OB_THEME"); + CREATE(ob_config_file, "_OB_CONFIG_FILE"); CREATE(ob_wm_action_undecorate, "_OB_WM_ACTION_UNDECORATE"); CREATE(ob_wm_state_undecorated, "_OB_WM_STATE_UNDECORATED"); CREATE(ob_control, "_OB_CONTROL");
M openbox/prop.hopenbox/prop.h

@@ -194,6 +194,7 @@ Atom ob_wm_action_undecorate;

Atom ob_wm_state_undecorated; Atom openbox_pid; /* this is depreecated in favour of ob_control */ Atom ob_theme; + Atom ob_config_file; Atom ob_control; } Atoms; extern Atoms prop_atoms;
M openbox/screen.copenbox/screen.c

@@ -300,6 +300,7 @@ supported[i++] = prop_atoms.ob_wm_action_undecorate;

supported[i++] = prop_atoms.ob_wm_state_undecorated; supported[i++] = prop_atoms.openbox_pid; supported[i++] = prop_atoms.ob_theme; + supported[i++] = prop_atoms.ob_config_file; supported[i++] = prop_atoms.ob_control; g_assert(i == num_support);
M parser/parse.cparser/parse.c

@@ -79,25 +79,21 @@ c->data = data;

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; }
M parser/parse.hparser/parse.h

@@ -35,10 +35,10 @@ ObParseInst* parse_startup();

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 */