From 311e2ff4379ee317d4c2abbbf862dccbb85f263c Mon Sep 17 00:00:00 2001 From: Sascha Kruse Date: Wed, 25 Jul 2012 09:39:03 +0200 Subject: [PATCH] reintroduced config.h --- Makefile | 6 +++++- config.def.h | 31 +++++++++++++++++++++++++++++++ config.mk | 6 ++++-- dunst.c | 45 +++++++++++---------------------------------- 4 files changed, 51 insertions(+), 37 deletions(-) create mode 100644 config.def.h diff --git a/Makefile b/Makefile index ed17495..2286d4c 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,11 @@ options: @echo CC -c $< @${CC} -c $< ${CFLAGS} -${OBJ}: config.mk +${OBJ}: config.h config.mk + +config.h: + @echo creating $@ from config.def.h + @cp config.def.h $@ dunst: draw.o dunst.o list.o dunst_dbus.o ini.o utils.o @echo CC -o $@ diff --git a/config.def.h b/config.def.h new file mode 100644 index 0000000..71a7057 --- /dev/null +++ b/config.def.h @@ -0,0 +1,31 @@ +/* see example dunstrc for additional explanations about these options */ + +char *font = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*"; +char *normbgcolor = "#1793D1"; +char *normfgcolor = "#DDDDDD"; +char *critbgcolor = "#ffaaaa"; +char *critfgcolor = "#000000"; +char *lowbgcolor = "#aaaaff"; +char *lowfgcolor = "#000000"; +char *format = "%s %b"; /* default format */ + +int timeouts[] = { 10, 10, 0 }; /* low, normal, critical */ + +char *geom = "0x0"; /* geometry */ +int sort = True; /* sort messages by urgency */ +int indicate_hidden = True; /* show count of hidden messages */ +int idle_threshold = 0; /* don't timeout notifications when idle for x seconds */ +int show_age_threshold = -1; /* show age of notification, when notification is older than x seconds */ +enum alignment align = left; /* text alignment [left/center/right] */ +int sticky_history = True; +int verbosity = 0; + +/* keyboard shortcuts */ +keyboard_shortcut close_ks = {.str = "ctrl+space", + .code = 0, .sym = NoSymbol,.is_valid = False}; /* ignore this */ + +keyboard_shortcut close_all_ks = {.str = "ctrl+shift+space", + .code = 0, .sym = NoSymbol,.is_valid = False}; /* ignore this */ + +keyboard_shortcut history_ks = {.str = "ctrl+grave", + .code = 0, .sym = NoSymbol,.is_valid = False}; /* ignore this */ diff --git a/config.mk b/config.mk index 443c4db..04e7dc1 100644 --- a/config.mk +++ b/config.mk @@ -7,7 +7,6 @@ VERSION="pre-0.3.0" X11INC = /usr/X11R6/include X11LIB = /usr/X11R6/lib -# Xft, comment if you don't want it XFTINC = -I/usr/include/freetype2 XFTLIBS = -lXft @@ -15,6 +14,9 @@ XFTLIBS = -lXft XINERAMALIBS = -lXinerama XINERAMAFLAGS = -DXINERAMA +# uncomment to disable parsing of dunstrc +STATIC= -DSTATIC_CONFIG + # inih flags INIFLAGS = -DINI_ALLOW_MULTILINE=0 @@ -24,5 +26,5 @@ LIBS = -L${X11LIB} -lX11 -lXss ${XFTLIBS} ${XINERAMALIBS} $(shell pkg-config --l # flags CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} ${INIFLAGS} -CFLAGS = -g --std=c99 -pedantic -Wall -Wno-overlength-strings -Os ${INCS} ${CPPFLAGS} +CFLAGS = -g --std=c99 -pedantic -Wall -Wno-overlength-strings -Os ${INCS} ${STATIC} ${CPPFLAGS} LDFLAGS = ${LIBS} diff --git a/dunst.c b/dunst.c index 3714e1b..875b323 100644 --- a/dunst.c +++ b/dunst.c @@ -26,6 +26,7 @@ #include "ini.h" #include "utils.h" + #define INRECT(x,y,rx,ry,rw,rh) ((x) >= (rx) && (x) < (rx)+(rw) && (y) >= (ry) && (y) < (ry)+(rh)) #define LENGTH(X) (sizeof X / sizeof X[0]) #define MIN(a,b) ((a) < (b) ? (a) : (b)) @@ -53,29 +54,14 @@ typedef struct _notification_buffer { int x_offset; } notification_buffer; + + + /* global variables */ - /* extern */ -int verbosity = 0; -char *font = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*"; -char *normbgcolor = "#1793D1"; -char *normfgcolor = "#DDDDDD"; -char *critbgcolor = "#ffaaaa"; -char *critfgcolor = "#000000"; -char *lowbgcolor = "#aaaaff"; -char *lowfgcolor = "#000000"; -char *format = "%s %b"; /* default format */ -int timeouts[] = { 10, 10, 0 }; /* low, normal, critical */ +#include "config.h" -char *geom = "0x0"; /* geometry */ int height_limit; -int sort = True; /* sort messages by urgency */ -int indicate_hidden = True; /* show count of hidden messages */ -int idle_threshold = 0; -int show_age_threshold = -1; -enum alignment align = left; -int sticky_history = True; - list *rules = NULL; /* index of colors fit to urgency level */ @@ -86,18 +72,6 @@ static DC *dc; static Window win; static time_t now; static int visible = False; -static keyboard_shortcut close_ks = {.str = NULL,.code = 0,.sym = - NoSymbol,.mask = 0,.is_valid = False -}; - -static keyboard_shortcut close_all_ks = {.str = NULL,.code = 0,.sym = - NoSymbol,.mask = 0,.is_valid = False -}; - -static keyboard_shortcut history_ks = {.str = NULL,.code = 0,.sym = - NoSymbol,.mask = 0,.is_valid = False -}; - static screen_info scr; static dimension_t geometry; static XScreenSaverInfo *screensaver_info; @@ -1265,6 +1239,7 @@ void parse_cmdline(int argc, char *argv[]) } } +#ifndef STATIC_CONFIG static int dunst_ini_get_boolean(const char *value) { switch (value[0]) { @@ -1448,7 +1423,6 @@ void parse_dunstrc(char *cmdline_config_path) FILE *config_file = NULL; xdgInitHandle(&xdg); - rules = l_init(); if (cmdline_config_path != NULL) { config_file = fopen(cmdline_config_path, "r"); @@ -1476,6 +1450,7 @@ void parse_dunstrc(char *cmdline_config_path) print_rules(); } +#endif /* STATIC_CONFIG */ char *parse_cmdline_for_config_file(int argc, char *argv[]) { @@ -1493,12 +1468,14 @@ char *parse_cmdline_for_config_file(int argc, char *argv[]) int main(int argc, char *argv[]) { - char *cmdline_config_path; now = time(&now); + rules = l_init(); +#ifndef STATIC_CONFIG + char *cmdline_config_path; cmdline_config_path = parse_cmdline_for_config_file(argc, argv); - parse_dunstrc(cmdline_config_path); +#endif parse_cmdline(argc, argv); dc = initdc();