Skip to content

Commit 78b6e2b

Browse files
committed
use libxdg-basedir to properly handle the xdg spec
1 parent 3ab5daf commit 78b6e2b

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

README.pod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ In order to do that you have to add a hint via the -h option.
131131
=head1 CONFIGURATION
132132

133133
An example configuration file is included (usually /usr/share/dunst/dunstrc).
134-
To change the configuration, copy this file to ~/.config/dunstrc and edit it
135-
accordingly.
134+
To change the configuration, copy this file to ~/.config/dunst/dunstrc and edit
135+
it accordingly.
136136

137137
=head1 AUTHOR
138138

config.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ XINERAMAFLAGS = -DXINERAMA
1717
INIFLAGS = -DINI_ALLOW_MULTILINE=0
1818

1919
# includes and libs
20-
INCS = -I${X11INC} $(shell pkg-config --cflags dbus-1) ${XFTINC}
21-
LIBS = -L${X11LIB} -lX11 -lXss ${XFTLIBS} ${XINERAMALIBS} $(shell pkg-config --libs dbus-1)
20+
INCS = -I${X11INC} $(shell pkg-config --cflags dbus-1 libxdg-basedir) ${XFTINC}
21+
LIBS = -L${X11LIB} -lX11 -lXss ${XFTLIBS} ${XINERAMALIBS} $(shell pkg-config --libs dbus-1 libxdg-basedir)
2222

2323
# flags
2424
CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} ${INIFLAGS}

dunst.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <X11/extensions/Xinerama.h>
1717
#endif
1818
#include <X11/extensions/scrnsaver.h>
19+
#include <basedir.h>
20+
#include <basedir_fs.h>
1921

2022
#include "dunst.h"
2123
#include "draw.h"
@@ -1056,33 +1058,27 @@ dunst_ini_handle(void *user_data, const char *section,
10561058
void
10571059
parse_dunstrc(void) {
10581060

1059-
char *config_path = NULL;
1061+
xdgHandle xdg;
1062+
FILE *config_file;
10601063

10611064
dunst_printf(DEBUG, "Begin parsing of dunstrc\n");
10621065

1063-
if (config_file == NULL) {
1064-
config_file = malloc(sizeof(char) * BUFSIZ);
1065-
memset(config_file, '\0', BUFSIZ);
1066-
1067-
config_path = getenv("XDG_CONFIG_HOME");
1068-
1069-
if (!config_path) {
1070-
puts("no dunstrc found -> skipping\n");
1071-
return;
1072-
}
1073-
1066+
xdgInitHandle(&xdg);
10741067

1075-
strcat(config_file, config_path);
1076-
strcat(config_file, "/");
1077-
strcat(config_file, "dunstrc");
1068+
config_file = xdgConfigOpen("dunst/dunstrc", "r", &xdg);
1069+
if (config_file == NULL) {
1070+
puts("no dunstrc found -> skipping\n");
1071+
xdgWipeHandle(&xdg);
1072+
return;
10781073
}
10791074

1080-
dunst_printf(DEBUG, "Reading %s\n", config_file);
1081-
1082-
if (ini_parse(config_file, dunst_ini_handle, NULL) < 0) {
1083-
puts("no dunstrc found -> skipping\n");
1075+
if (ini_parse_file(config_file, dunst_ini_handle, NULL) < 0) {
1076+
puts("dunstrc could not be parsed -> skipping\n");
10841077
}
10851078

1079+
fclose(config_file);
1080+
xdgWipeHandle(&xdg);
1081+
10861082
print_rules();
10871083
}
10881084

0 commit comments

Comments
 (0)