Implement option parsing (-c <configfile>)

This commit is contained in:
Michael Stapelberg 2009-03-04 16:06:39 +01:00
parent a02b861826
commit f90563011f
2 changed files with 32 additions and 16 deletions

View File

@ -9,7 +9,7 @@ i3 - an improved dynamic, tiling window manager
== SYNOPSIS == SYNOPSIS
i3 i3 [-c configfile]
== DESCRIPTION == DESCRIPTION
@ -101,11 +101,12 @@ Enable default layout for the current container.
== FILES == FILES
=== i3.config === ~/.i3/config
When starting, i3 looks for i3.config in the current working directory and loads the When starting, i3 looks for ~/.i3/config and loads the configuration. If ~/.i3/config is not found,
configuration. At the moment, you can specify only the path to your favorite terminal i3 tries /etc/i3/config. You can specify a custom path using the -c option.
emulator, the font and keybindings.
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)). 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_MEASUREMENT=de_DE.ISO8859-15
export LC_IDENTIFICATION=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 == 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: Here is an overwiew of the most important points:
* IPC * IPC
* a command for toggling layouts/workspaces
* floating * floating
* do something about applications which dont use _NET_WM_STATE_FULLSCREEN (like xpdf) * do something about applications which dont use _NET_WM_STATE_FULLSCREEN (like xpdf)

View File

@ -18,11 +18,10 @@
#include <assert.h> #include <assert.h>
#include <limits.h> #include <limits.h>
#include <xcb/xcb.h>
#include <X11/XKBlib.h> #include <X11/XKBlib.h>
#include <X11/extensions/XKB.h> #include <X11/extensions/XKB.h>
#include <xcb/xcb.h>
#include <xcb/xcb_wm.h> #include <xcb/xcb_wm.h>
#include <xcb/xcb_aux.h> #include <xcb/xcb_aux.h>
#include <xcb/xcb_event.h> #include <xcb/xcb_event.h>
@ -30,18 +29,18 @@
#include <xcb/xcb_keysyms.h> #include <xcb/xcb_keysyms.h>
#include <xcb/xcb_icccm.h> #include <xcb/xcb_icccm.h>
#include <xcb/xinerama.h> #include <xcb/xinerama.h>
#include "data.h"
#include "config.h" #include "config.h"
#include "queue.h" #include "data.h"
#include "table.h"
#include "layout.h"
#include "debug.h" #include "debug.h"
#include "handlers.h" #include "handlers.h"
#include "i3.h"
#include "layout.h"
#include "queue.h"
#include "table.h"
#include "util.h" #include "util.h"
#include "xcb.h" #include "xcb.h"
#include "xinerama.h" #include "xinerama.h"
#include "i3.h"
/* This is the path to i3, copied from argv[0] when starting up */ /* This is the path to i3, copied from argv[0] when starting up */
char *application_path; 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 main(int argc, char *argv[], char *env[]) {
int i, screens; int i, screens, opt;
char *override_configpath = NULL;
xcb_connection_t *conn; xcb_connection_t *conn;
xcb_property_handlers_t prophs; xcb_property_handlers_t prophs;
xcb_window_t root; xcb_window_t root;
@ -294,6 +294,17 @@ int main(int argc, char *argv[], char *env[]) {
application_path = sstrdup(argv[0]); 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 */ /* Initialize the table data structures for each workspace */
init_table(); init_table();
@ -303,7 +314,7 @@ int main(int argc, char *argv[], char *env[]) {
byChild = alloc_table(); byChild = alloc_table();
byParent = alloc_table(); byParent = alloc_table();
load_configuration(NULL); load_configuration(override_configpath);
conn = xcb_connect(NULL, &screens); conn = xcb_connect(NULL, &screens);