dwm-meillo
changeset 146:f328ce9c558c
centralized/externalized configuration to config.h
author | arg@10ksloc.org |
---|---|
date | Tue, 01 Aug 2006 13:59:13 +0200 |
parents | 774754477c35 |
children | a94577c9de73 |
files | README config.arg.h config.h config.mk dwm.1 dwm.h event.c main.c tag.c |
diffstat | 9 files changed, 171 insertions(+), 106 deletions(-) [+] |
line diff
1.1 --- a/README Tue Aug 01 12:41:38 2006 +0200 1.2 +++ b/README Tue Aug 01 13:59:13 2006 +0200 1.3 @@ -18,6 +18,11 @@ 1.4 1.5 make clean install 1.6 1.7 +If you want to use a customized config.h, you can use the following 1.8 +command for installing dwm: 1.9 + 1.10 + make CONFIG=<your-config>.h clean install 1.11 + 1.12 1.13 Running dwm 1.14 ----------- 1.15 @@ -47,5 +52,4 @@ 1.16 1.17 Configuration 1.18 ------------- 1.19 -The configuration of dwm is done by customizing its source code 1.20 -(grep for the CUSTOMIZE keyword). 1.21 +The configuration of dwm is done by editing config.h.
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/config.arg.h Tue Aug 01 13:59:13 2006 +0200 2.3 @@ -0,0 +1,76 @@ 2.4 +/* 2.5 + * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 2.6 + * See LICENSE file for license details. 2.7 + */ 2.8 + 2.9 +#define FONT "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*" 2.10 +#define BGCOLOR "#0a2c2d" 2.11 +#define FGCOLOR "#ddeeee" 2.12 +#define BORDERCOLOR "#176164" 2.13 +#define MODKEY Mod1Mask 2.14 +#define NUMLOCKMASK Mod2Mask 2.15 +#define MASTERW 52 /* percent */ 2.16 +#define WM_PROTOCOL_DELWIN 1 2.17 + 2.18 +enum { Tfnord, Tdev, Tnet, Twork, Tmisc, TLast }; 2.19 +#define TAGS \ 2.20 +char *tags[TLast] = { \ 2.21 + [Tfnord] = "fnord", \ 2.22 + [Tdev] = "dev", \ 2.23 + [Tnet] = "net", \ 2.24 + [Twork] = "work", \ 2.25 + [Tmisc] = "misc", \ 2.26 +}; 2.27 +#define DEFTAG Tdev 2.28 + 2.29 + 2.30 +#define CMDS \ 2.31 + const char *browse[] = { "firefox", NULL }; \ 2.32 + const char *gimp[] = { "gimp", NULL }; \ 2.33 + const char *term[] = { \ 2.34 + "urxvt", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white", \ 2.35 + "-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", NULL \ 2.36 + }; \ 2.37 + const char *xlock[] = { "xlock", NULL }; 2.38 + 2.39 +#define KEYS \ 2.40 +static Key key[] = { \ 2.41 + /* modifier key function arguments */ \ 2.42 + { MODKEY, XK_0, view, { .i = Tfnord } }, \ 2.43 + { MODKEY, XK_1, view, { .i = Tdev } }, \ 2.44 + { MODKEY, XK_2, view, { .i = Tnet } }, \ 2.45 + { MODKEY, XK_3, view, { .i = Twork } }, \ 2.46 + { MODKEY, XK_4, view, { .i = Tmisc} }, \ 2.47 + { MODKEY, XK_h, viewprev, { 0 } }, \ 2.48 + { MODKEY, XK_j, focusnext, { 0 } }, \ 2.49 + { MODKEY, XK_k, focusprev, { 0 } }, \ 2.50 + { MODKEY, XK_l, viewnext, { 0 } }, \ 2.51 + { MODKEY, XK_m, togglemax, { 0 } }, \ 2.52 + { MODKEY, XK_space, togglemode, { 0 } }, \ 2.53 + { MODKEY, XK_Return, zoom, { 0 } }, \ 2.54 + { MODKEY|ControlMask, XK_0, appendtag, { .i = Tfnord } }, \ 2.55 + { MODKEY|ControlMask, XK_1, appendtag, { .i = Tdev } }, \ 2.56 + { MODKEY|ControlMask, XK_2, appendtag, { .i = Tnet } }, \ 2.57 + { MODKEY|ControlMask, XK_3, appendtag, { .i = Twork } }, \ 2.58 + { MODKEY|ControlMask, XK_4, appendtag, { .i = Tmisc } }, \ 2.59 + { MODKEY|ShiftMask, XK_0, replacetag, { .i = Tfnord } }, \ 2.60 + { MODKEY|ShiftMask, XK_1, replacetag, { .i = Tdev } }, \ 2.61 + { MODKEY|ShiftMask, XK_2, replacetag, { .i = Tnet } }, \ 2.62 + { MODKEY|ShiftMask, XK_3, replacetag, { .i = Twork } }, \ 2.63 + { MODKEY|ShiftMask, XK_4, replacetag, { .i = Tmisc } }, \ 2.64 + { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ 2.65 + { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ 2.66 + { MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } }, \ 2.67 + { MODKEY|ShiftMask, XK_g, spawn, { .argv = gimp } }, \ 2.68 + { MODKEY|ShiftMask, XK_l, spawn, { .argv = xlock } }, \ 2.69 + { MODKEY|ShiftMask, XK_w, spawn, { .argv = browse } }, \ 2.70 +}; 2.71 + 2.72 +#define RULES \ 2.73 +static Rule rule[] = { \ 2.74 + /* class:instance tags isfloat */ \ 2.75 + { "Firefox.*", { [Tnet] = "net" }, False }, \ 2.76 + { "Gimp.*", { 0 }, True}, \ 2.77 +}; 2.78 + 2.79 +#define ARRANGE dotile
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/config.h Tue Aug 01 13:59:13 2006 +0200 3.3 @@ -0,0 +1,67 @@ 3.4 +/* 3.5 + * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 3.6 + * See LICENSE file for license details. 3.7 + */ 3.8 + 3.9 +#define FONT "fixed" 3.10 +#define BGCOLOR "#666699" 3.11 +#define FGCOLOR "#eeeeee" 3.12 +#define BORDERCOLOR "#9999CC" 3.13 +#define MODKEY Mod1Mask 3.14 +#define NUMLOCKMASK Mod2Mask 3.15 +#define MASTERW 52 /* percent */ 3.16 +#define WM_PROTOCOL_DELWIN 1 3.17 + 3.18 +enum { Tfnord, Tdev, Tnet, Twork, Tmisc, TLast }; 3.19 +#define TAGS \ 3.20 +char *tags[TLast] = { \ 3.21 + [Tfnord] = "fnord", \ 3.22 + [Tdev] = "dev", \ 3.23 + [Tnet] = "net", \ 3.24 + [Twork] = "work", \ 3.25 + [Tmisc] = "misc", \ 3.26 +}; 3.27 +#define DEFTAG Tdev 3.28 + 3.29 + 3.30 +#define CMDS \ 3.31 + const char *term[] = { "xterm", NULL }; 3.32 + 3.33 +#define KEYS \ 3.34 +static Key key[] = { \ 3.35 + /* modifier key function arguments */ \ 3.36 + { MODKEY, XK_0, view, { .i = Tfnord } }, \ 3.37 + { MODKEY, XK_1, view, { .i = Tdev } }, \ 3.38 + { MODKEY, XK_2, view, { .i = Tnet } }, \ 3.39 + { MODKEY, XK_3, view, { .i = Twork } }, \ 3.40 + { MODKEY, XK_4, view, { .i = Tmisc} }, \ 3.41 + { MODKEY, XK_h, viewprev, { 0 } }, \ 3.42 + { MODKEY, XK_j, focusnext, { 0 } }, \ 3.43 + { MODKEY, XK_k, focusprev, { 0 } }, \ 3.44 + { MODKEY, XK_l, viewnext, { 0 } }, \ 3.45 + { MODKEY, XK_m, togglemax, { 0 } }, \ 3.46 + { MODKEY, XK_space, togglemode, { 0 } }, \ 3.47 + { MODKEY, XK_Return, zoom, { 0 } }, \ 3.48 + { MODKEY|ControlMask, XK_0, appendtag, { .i = Tfnord } }, \ 3.49 + { MODKEY|ControlMask, XK_1, appendtag, { .i = Tdev } }, \ 3.50 + { MODKEY|ControlMask, XK_2, appendtag, { .i = Tnet } }, \ 3.51 + { MODKEY|ControlMask, XK_3, appendtag, { .i = Twork } }, \ 3.52 + { MODKEY|ControlMask, XK_4, appendtag, { .i = Tmisc } }, \ 3.53 + { MODKEY|ShiftMask, XK_0, replacetag, { .i = Tfnord } }, \ 3.54 + { MODKEY|ShiftMask, XK_1, replacetag, { .i = Tdev } }, \ 3.55 + { MODKEY|ShiftMask, XK_2, replacetag, { .i = Tnet } }, \ 3.56 + { MODKEY|ShiftMask, XK_3, replacetag, { .i = Twork } }, \ 3.57 + { MODKEY|ShiftMask, XK_4, replacetag, { .i = Tmisc } }, \ 3.58 + { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ 3.59 + { MODKEY|ShiftMask, XK_q, quit, { 0 } }, \ 3.60 + { MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } }, \ 3.61 +}; 3.62 + 3.63 +#define RULES \ 3.64 +static Rule rule[] = { \ 3.65 + /* class:instance tags isfloat */ \ 3.66 + { "Firefox.*", { [Tnet] = "net" }, False }, \ 3.67 + { "Gimp.*", { 0 }, True}, \ 3.68 +}; 3.69 + 3.70 +#define ARRANGE dotile
4.1 --- a/config.mk Tue Aug 01 12:41:38 2006 +0200 4.2 +++ b/config.mk Tue Aug 01 13:59:13 2006 +0200 4.3 @@ -12,9 +12,9 @@ 4.4 LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 4.5 4.6 # flags 4.7 -CFLAGS = -O3 ${INCS} -DVERSION=\"${VERSION}\" 4.8 +CFLAGS = -O3 ${INCS} -DVERSION=\"${VERSION}\" -DCONFIG=\"${CONFIG}\" 4.9 LDFLAGS = ${LIBS} 4.10 -#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" 4.11 +#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" -DCONFIG=\"${CONFIGH}\" 4.12 #LDFLAGS = -g ${LIBS} 4.13 4.14 # compiler 4.15 @@ -22,3 +22,6 @@ 4.16 4.17 # dwm version 4.18 VERSION = 0.6 4.19 + 4.20 +# default config.h 4.21 +CONFIG = config.h
5.1 --- a/dwm.1 Tue Aug 01 12:41:38 2006 +0200 5.2 +++ b/dwm.1 Tue Aug 01 13:59:13 2006 +0200 5.3 @@ -98,7 +98,5 @@ 5.4 while dragging 5.5 .SH CUSTOMIZATION 5.6 .B dwm 5.7 -is customized through editing its source code. This keeps it fast, secure and 5.8 -simple. The source code contains the 5.9 -.I CUSTOMIZE 5.10 -keyword to highlight relevant portions for customization. 5.11 +is customized through editing config.h of the source code. This keeps it fast, 5.12 +secure and simple.
6.1 --- a/dwm.h Tue Aug 01 12:41:38 2006 +0200 6.2 +++ b/dwm.h Tue Aug 01 13:59:13 2006 +0200 6.3 @@ -4,26 +4,7 @@ 6.4 */ 6.5 6.6 #include <X11/Xlib.h> 6.7 - 6.8 -/* CUSTOMIZE */ 6.9 - 6.10 -#define FONT "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*" 6.11 -#define BGCOLOR "#0a2c2d" 6.12 -#define FGCOLOR "#ddeeee" 6.13 -#define BORDERCOLOR "#176164" 6.14 -#define MODKEY Mod1Mask /* Mod4Mask */ 6.15 -/* 6.16 -#define BGCOLOR "#666699" 6.17 -#define FGCOLOR "#eeeeee" 6.18 -#define BORDERCOLOR "#9999CC" 6.19 -*/ 6.20 -#define MASTERW 52 /* percent */ 6.21 -#define WM_PROTOCOL_DELWIN 1 6.22 - 6.23 -/* tags */ 6.24 -enum { Tfnord, Tdev, Tnet, Twork, Tmisc, TLast }; 6.25 - 6.26 -/* END CUSTOMIZE */ 6.27 +#include CONFIG 6.28 6.29 /* mask shorthands, used in event.c and client.c */ 6.30 #define ButtonMask (ButtonPressMask | ButtonReleaseMask)
7.1 --- a/event.c Tue Aug 01 12:41:38 2006 +0200 7.2 +++ b/event.c Tue Aug 01 13:59:13 2006 +0200 7.3 @@ -8,7 +8,7 @@ 7.4 #include <X11/keysym.h> 7.5 #include <X11/Xatom.h> 7.6 7.7 -/* CUSTOMIZE */ 7.8 +/* static */ 7.9 7.10 typedef struct { 7.11 unsigned long mod; 7.12 @@ -17,52 +17,10 @@ 7.13 Arg arg; 7.14 } Key; 7.15 7.16 -const char *browse[] = { "firefox", NULL }; 7.17 -const char *gimp[] = { "gimp", NULL }; 7.18 -const char *term[] = { /*"xterm", NULL };*/ 7.19 - "urxvt", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white", 7.20 - "-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", NULL 7.21 -}; 7.22 -const char *xlock[] = { "xlock", NULL }; 7.23 +CMDS 7.24 +KEYS 7.25 7.26 -static Key key[] = { 7.27 - /* modifier key function arguments */ 7.28 - { MODKEY, XK_0, view, { .i = Tfnord } }, 7.29 - { MODKEY, XK_1, view, { .i = Tdev } }, 7.30 - { MODKEY, XK_2, view, { .i = Tnet } }, 7.31 - { MODKEY, XK_3, view, { .i = Twork } }, 7.32 - { MODKEY, XK_4, view, { .i = Tmisc} }, 7.33 - { MODKEY, XK_h, viewprev, { 0 } }, 7.34 - { MODKEY, XK_j, focusnext, { 0 } }, 7.35 - { MODKEY, XK_k, focusprev, { 0 } }, 7.36 - { MODKEY, XK_l, viewnext, { 0 } }, 7.37 - { MODKEY, XK_m, togglemax, { 0 } }, 7.38 - { MODKEY, XK_space, togglemode, { 0 } }, 7.39 - { MODKEY, XK_Return, zoom, { 0 } }, 7.40 - { MODKEY|ControlMask, XK_0, appendtag, { .i = Tfnord } }, 7.41 - { MODKEY|ControlMask, XK_1, appendtag, { .i = Tdev } }, 7.42 - { MODKEY|ControlMask, XK_2, appendtag, { .i = Tnet } }, 7.43 - { MODKEY|ControlMask, XK_3, appendtag, { .i = Twork } }, 7.44 - { MODKEY|ControlMask, XK_4, appendtag, { .i = Tmisc } }, 7.45 - { MODKEY|ShiftMask, XK_0, replacetag, { .i = Tfnord } }, 7.46 - { MODKEY|ShiftMask, XK_1, replacetag, { .i = Tdev } }, 7.47 - { MODKEY|ShiftMask, XK_2, replacetag, { .i = Tnet } }, 7.48 - { MODKEY|ShiftMask, XK_3, replacetag, { .i = Twork } }, 7.49 - { MODKEY|ShiftMask, XK_4, replacetag, { .i = Tmisc } }, 7.50 - { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, 7.51 - { MODKEY|ShiftMask, XK_q, quit, { 0 } }, 7.52 - { MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } }, 7.53 - { MODKEY|ShiftMask, XK_g, spawn, { .argv = gimp } }, 7.54 - { MODKEY|ShiftMask, XK_l, spawn, { .argv = xlock } }, 7.55 - { MODKEY|ShiftMask, XK_w, spawn, { .argv = browse } }, 7.56 -}; 7.57 - 7.58 -#define NumLockMask Mod2Mask 7.59 -unsigned int valid_mask = 255 & ~( NumLockMask | LockMask); 7.60 - 7.61 -/* END CUSTOMIZE */ 7.62 - 7.63 -/* static */ 7.64 +static unsigned int valid_mask = 255 & ~(NUMLOCKMASK | LockMask); 7.65 7.66 static void 7.67 movemouse(Client *c) 7.68 @@ -381,19 +339,13 @@ 7.69 for(i = 0; i < len; i++) { 7.70 code = XKeysymToKeycode(dpy, key[i].keysym); 7.71 XUngrabKey(dpy, code, key[i].mod, root); 7.72 - if (NumLockMask) 7.73 - { 7.74 - XUngrabKey(dpy, code, key[i].mod | NumLockMask, root); 7.75 - XUngrabKey(dpy, code, key[i].mod | NumLockMask | LockMask, root); 7.76 - } 7.77 + XUngrabKey(dpy, code, key[i].mod | NUMLOCKMASK, root); 7.78 + XUngrabKey(dpy, code, key[i].mod | NUMLOCKMASK | LockMask, root); 7.79 XGrabKey(dpy, code, key[i].mod, root, True, 7.80 GrabModeAsync, GrabModeAsync); 7.81 - if (NumLockMask) 7.82 - { 7.83 - XGrabKey(dpy, code, key[i].mod | NumLockMask, root, True, 7.84 - GrabModeAsync, GrabModeAsync); 7.85 - XGrabKey(dpy, code, key[i].mod | NumLockMask | LockMask, root, True, 7.86 - GrabModeAsync, GrabModeAsync); 7.87 - } 7.88 + XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK, root, True, 7.89 + GrabModeAsync, GrabModeAsync); 7.90 + XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK | LockMask, root, True, 7.91 + GrabModeAsync, GrabModeAsync); 7.92 } 7.93 }
8.1 --- a/main.c Tue Aug 01 12:41:38 2006 +0200 8.2 +++ b/main.c Tue Aug 01 13:59:13 2006 +0200 8.3 @@ -85,9 +85,7 @@ 8.4 /* extern */ 8.5 8.6 char stext[1024]; 8.7 -/* CUSTOMIZE */ 8.8 -int tsel = Tdev; /* default tag */ 8.9 -/* END CUSTOMIZE */ 8.10 +int tsel = DEFTAG; 8.11 int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; 8.12 Atom wmatom[WMLast], netatom[NetLast]; 8.13 Bool running = True;
9.1 --- a/tag.c Tue Aug 01 12:41:38 2006 +0200 9.2 +++ b/tag.c Tue Aug 01 13:59:13 2006 +0200 9.3 @@ -18,24 +18,10 @@ 9.4 Bool isfloat; 9.5 } Rule; 9.6 9.7 -/* CUSTOMIZE */ 9.8 -static Rule rule[] = { 9.9 - /* class:instance tags isfloat */ 9.10 - { "Firefox.*", { [Tnet] = "net" }, False }, 9.11 - { "Gimp.*", { 0 }, True}, 9.12 -}; 9.13 +TAGS 9.14 +RULES 9.15 9.16 -char *tags[TLast] = { 9.17 - [Tfnord] = "fnord", 9.18 - [Tdev] = "dev", 9.19 - [Tnet] = "net", 9.20 - [Twork] = "work", 9.21 - [Tmisc] = "misc", 9.22 -}; 9.23 - 9.24 -void (*arrange)(Arg *) = dotile; 9.25 - 9.26 -/* END CUSTOMIZE */ 9.27 +void (*arrange)(Arg *) = ARRANGE; 9.28 9.29 /* extern */ 9.30