From f90563011f8cc36b4b3f191d6d69dfb8d8285c03 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 4 Mar 2009 16:06:39 +0100 Subject: [PATCH] Implement option parsing (-c ) --- man/i3.man | 19 ++++++++++++------- src/mainx.c | 29 ++++++++++++++++++++--------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/man/i3.man b/man/i3.man index fc62ef37..789862c5 100644 --- a/man/i3.man +++ b/man/i3.man @@ -9,7 +9,7 @@ i3 - an improved dynamic, tiling window manager == SYNOPSIS -i3 +i3 [-c configfile] == DESCRIPTION @@ -101,11 +101,12 @@ Enable default layout for the current container. == FILES -=== i3.config +=== ~/.i3/config -When starting, i3 looks for i3.config in the current working directory and loads the -configuration. At the moment, you can specify only the path to your favorite terminal -emulator, the font and keybindings. +When starting, i3 looks for ~/.i3/config and loads the configuration. If ~/.i3/config is not found, +i3 tries /etc/i3/config. You can specify a custom path using the -c option. + +At the moment, you can specify only the path to your favorite terminal emulator, the font and keybindings. At the moment, you have to bind to keycodes (find them out via xev(1)). @@ -182,7 +183,12 @@ export LC_TELEPHONE=de_DE.ISO8859-15 export LC_MEASUREMENT=de_DE.ISO8859-15 export LC_IDENTIFICATION=de_DE.ISO8859-15 -exec /usr/bin/i3 +# Enable core dumps in case something goes wrong +ulimit -c unlimited + +# Start i3 and log to ~/.i3/logfile +echo "Starting at $(date)" >> ~/.i3/logfile +exec /usr/bin/i3 >> ~/.i3/logfile ------------------------------------------------------------- == TODO @@ -191,7 +197,6 @@ There is lots of stuff left to do. This release is to be considered as a technol Here is an overwiew of the most important points: * IPC - * a command for toggling layouts/workspaces * floating * do something about applications which don’t use _NET_WM_STATE_FULLSCREEN (like xpdf) diff --git a/src/mainx.c b/src/mainx.c index 32dc77e5..9927af6f 100644 --- a/src/mainx.c +++ b/src/mainx.c @@ -18,11 +18,10 @@ #include #include -#include - #include #include +#include #include #include #include @@ -30,18 +29,18 @@ #include #include #include -#include "data.h" #include "config.h" -#include "queue.h" -#include "table.h" -#include "layout.h" +#include "data.h" #include "debug.h" #include "handlers.h" +#include "i3.h" +#include "layout.h" +#include "queue.h" +#include "table.h" #include "util.h" #include "xcb.h" #include "xinerama.h" -#include "i3.h" /* This is the path to i3, copied from argv[0] when starting up */ char *application_path; @@ -282,7 +281,8 @@ void manage_existing_windows(xcb_connection_t *conn, xcb_property_handlers_t *pr } int main(int argc, char *argv[], char *env[]) { - int i, screens; + int i, screens, opt; + char *override_configpath = NULL; xcb_connection_t *conn; xcb_property_handlers_t prophs; xcb_window_t root; @@ -294,6 +294,17 @@ int main(int argc, char *argv[], char *env[]) { application_path = sstrdup(argv[0]); + while ((opt = getopt(argc, argv, "c:")) != -1) { + switch (opt) { + case 'c': + override_configpath = sstrdup(optarg); + break; + default: + fprintf(stderr, "Usage: %s [-c configfile]\n", argv[0]); + exit(EXIT_FAILURE); + } + } + /* Initialize the table data structures for each workspace */ init_table(); @@ -303,7 +314,7 @@ int main(int argc, char *argv[], char *env[]) { byChild = alloc_table(); byParent = alloc_table(); - load_configuration(NULL); + load_configuration(override_configpath); conn = xcb_connect(NULL, &screens);