|
16 | 16 | #include <X11/extensions/Xinerama.h> |
17 | 17 | #endif |
18 | 18 | #include <X11/extensions/scrnsaver.h> |
| 19 | +#include <basedir.h> |
| 20 | +#include <basedir_fs.h> |
19 | 21 |
|
20 | 22 | #include "dunst.h" |
21 | 23 | #include "draw.h" |
@@ -1056,33 +1058,27 @@ dunst_ini_handle(void *user_data, const char *section, |
1056 | 1058 | void |
1057 | 1059 | parse_dunstrc(void) { |
1058 | 1060 |
|
1059 | | - char *config_path = NULL; |
| 1061 | + xdgHandle xdg; |
| 1062 | + FILE *config_file; |
1060 | 1063 |
|
1061 | 1064 | dunst_printf(DEBUG, "Begin parsing of dunstrc\n"); |
1062 | 1065 |
|
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); |
1074 | 1067 |
|
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; |
1078 | 1073 | } |
1079 | 1074 |
|
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"); |
1084 | 1077 | } |
1085 | 1078 |
|
| 1079 | + fclose(config_file); |
| 1080 | + xdgWipeHandle(&xdg); |
| 1081 | + |
1086 | 1082 | print_rules(); |
1087 | 1083 | } |
1088 | 1084 |
|
|
0 commit comments