From 3ab5daf2d1316847e15ded7baed2892f67129e7b Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 23 Jun 2012 20:10:52 +0200 Subject: [PATCH 1/3] Use pkg-config to figure out libdbus cflags/libs This fixes compilation on recent Debian multiarch systems. --- config.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.mk b/config.mk index 2af7fd8..891807e 100644 --- a/config.mk +++ b/config.mk @@ -17,8 +17,8 @@ XINERAMAFLAGS = -DXINERAMA INIFLAGS = -DINI_ALLOW_MULTILINE=0 # includes and libs -INCS = -I${X11INC} -I/usr/lib/dbus-1.0/include -I/usr/include/dbus-1.0 ${XFTINC} -LIBS = -L${X11LIB} -lX11 -lXss -ldbus-1 ${XFTLIBS} ${XINERAMALIBS} +INCS = -I${X11INC} $(shell pkg-config --cflags dbus-1) ${XFTINC} +LIBS = -L${X11LIB} -lX11 -lXss ${XFTLIBS} ${XINERAMALIBS} $(shell pkg-config --libs dbus-1) # flags CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} ${INIFLAGS} From 78b6e2b19f1595b4c6ad38225f667a24d522a576 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 23 Jun 2012 20:12:31 +0200 Subject: [PATCH 2/3] use libxdg-basedir to properly handle the xdg spec --- README.pod | 4 ++-- config.mk | 4 ++-- dunst.c | 36 ++++++++++++++++-------------------- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/README.pod b/README.pod index 76ee4f1..489a4a9 100644 --- a/README.pod +++ b/README.pod @@ -131,8 +131,8 @@ In order to do that you have to add a hint via the -h option. =head1 CONFIGURATION An example configuration file is included (usually /usr/share/dunst/dunstrc). -To change the configuration, copy this file to ~/.config/dunstrc and edit it -accordingly. +To change the configuration, copy this file to ~/.config/dunst/dunstrc and edit +it accordingly. =head1 AUTHOR diff --git a/config.mk b/config.mk index 891807e..a79f899 100644 --- a/config.mk +++ b/config.mk @@ -17,8 +17,8 @@ XINERAMAFLAGS = -DXINERAMA INIFLAGS = -DINI_ALLOW_MULTILINE=0 # includes and libs -INCS = -I${X11INC} $(shell pkg-config --cflags dbus-1) ${XFTINC} -LIBS = -L${X11LIB} -lX11 -lXss ${XFTLIBS} ${XINERAMALIBS} $(shell pkg-config --libs dbus-1) +INCS = -I${X11INC} $(shell pkg-config --cflags dbus-1 libxdg-basedir) ${XFTINC} +LIBS = -L${X11LIB} -lX11 -lXss ${XFTLIBS} ${XINERAMALIBS} $(shell pkg-config --libs dbus-1 libxdg-basedir) # flags CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} ${INIFLAGS} diff --git a/dunst.c b/dunst.c index 8cdbc8b..ad1db2a 100644 --- a/dunst.c +++ b/dunst.c @@ -16,6 +16,8 @@ #include #endif #include +#include +#include #include "dunst.h" #include "draw.h" @@ -1056,33 +1058,27 @@ dunst_ini_handle(void *user_data, const char *section, void parse_dunstrc(void) { - char *config_path = NULL; + xdgHandle xdg; + FILE *config_file; dunst_printf(DEBUG, "Begin parsing of dunstrc\n"); + xdgInitHandle(&xdg); + + config_file = xdgConfigOpen("dunst/dunstrc", "r", &xdg); if (config_file == NULL) { - config_file = malloc(sizeof(char) * BUFSIZ); - memset(config_file, '\0', BUFSIZ); - - config_path = getenv("XDG_CONFIG_HOME"); - - if (!config_path) { - puts("no dunstrc found -> skipping\n"); - return; - } - - - strcat(config_file, config_path); - strcat(config_file, "/"); - strcat(config_file, "dunstrc"); - } - - dunst_printf(DEBUG, "Reading %s\n", config_file); - - if (ini_parse(config_file, dunst_ini_handle, NULL) < 0) { puts("no dunstrc found -> skipping\n"); + xdgWipeHandle(&xdg); + return; } + if (ini_parse_file(config_file, dunst_ini_handle, NULL) < 0) { + puts("dunstrc could not be parsed -> skipping\n"); + } + + fclose(config_file); + xdgWipeHandle(&xdg); + print_rules(); } From a5f64fc938d5dac16fe179c722af994e6103a107 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 23 Jun 2012 20:16:04 +0200 Subject: [PATCH 3/3] add fallback to the old dunstrc path --- dunst.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dunst.c b/dunst.c index ad1db2a..afc70fa 100644 --- a/dunst.c +++ b/dunst.c @@ -1067,9 +1067,14 @@ parse_dunstrc(void) { config_file = xdgConfigOpen("dunst/dunstrc", "r", &xdg); if (config_file == NULL) { - puts("no dunstrc found -> skipping\n"); - xdgWipeHandle(&xdg); - return; + /* Fall back to just "dunstrc", which was used before 2012-06-23 + * (before v0.2). */ + config_file = xdgConfigOpen("dunstrc", "r", &xdg); + if (config_file == NULL) { + puts("no dunstrc found -> skipping\n"); + xdgWipeHandle(&xdg); + return; + } } if (ini_parse_file(config_file, dunst_ini_handle, NULL) < 0) {