summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2008-02-02 09:22:50 -0500
committerDana Jansens <danakj@orodu.net>2008-02-02 09:45:33 -0500
commitbbad88aa21f01a70faf824cbb2825bd7f9d95253 (patch)
treeb2800fc898f08a6fc3d91ec2bb6b21acc9ee16d6 /openbox
parent674c042c68602fbe19d525a697b35870b7029b41 (diff)
add a --config-file command line option, and OB_CONFIG_FILE root hint
Diffstat (limited to 'openbox')
-rw-r--r--openbox/openbox.c37
-rw-r--r--openbox/prop.c1
-rw-r--r--openbox/prop.h1
-rw-r--r--openbox/screen.c1
4 files changed, 33 insertions, 7 deletions
diff --git a/openbox/openbox.c b/openbox/openbox.c
index 18c34d2f..7d7e0d0d 100644
--- a/openbox/openbox.c
+++ b/openbox/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 @@ gint main(gint argc, gchar **argv)
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 @@ static void print_help()
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"));
@@ -566,6 +577,18 @@ static void parse_args(gint *argc, gchar **argv)
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 */
diff --git a/openbox/prop.c b/openbox/prop.c
index c4b8baea..c2b0b40f 100644
--- a/openbox/prop.c
+++ b/openbox/prop.c
@@ -172,6 +172,7 @@ void prop_startup(void)
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");
diff --git a/openbox/prop.h b/openbox/prop.h
index 5ca70470..464fe26d 100644
--- a/openbox/prop.h
+++ b/openbox/prop.h
@@ -194,6 +194,7 @@ typedef struct Atoms {
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;
diff --git a/openbox/screen.c b/openbox/screen.c
index 932b157e..73429bc9 100644
--- a/openbox/screen.c
+++ b/openbox/screen.c
@@ -300,6 +300,7 @@ gboolean screen_annex(void)
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);