Remove libxdg-basedir dependency

GLib's g_get_user_config_dir function does exactly the same thing and
we don't need libxdg-basedir for something else.
This commit is contained in:
Benedikt Heine 2018-10-01 19:56:00 +02:00
parent 0306446efb
commit 403e4cc176
6 changed files with 34 additions and 32 deletions

View File

@ -8,7 +8,6 @@ addons:
- libxrandr-dev
- libxinerama-dev
- libxss-dev
- libxdg-basedir-dev
- libglib2.0-dev
- libpango1.0-dev
- libcairo2-dev

View File

@ -1,14 +1,3 @@
{
xdgBaseDir_leak
# see https://github.com/devnev/libxdg-basedir/pull/6
Memcheck:Leak
fun:malloc
...
fun:xdgInitHandle
...
fun:main
}
# librsvg leaks some memory, when an invalid svg file is read
# TODO: find the memory leak and fix it upstream
{

View File

@ -4,6 +4,7 @@
### Added
- Remove libxdg-basedir dependency (GLib's function is used instead)
- `fullscreen` rule to hide notifications when a fullscreen window is active
- When new notifications arrive, but display is full, important notifications don't
have to wait for a timeout in a displayed notification (#541)

View File

@ -22,7 +22,6 @@ Dunst has a number of build dependencies that must be present before attempting
- libxinerama
- libxrandr
- libxss
- libxdg-basedir
- glib
- pango/cairo
- libgtk-3-dev

View File

@ -32,10 +32,7 @@ pkg_config_packs := dbus-1 \
"xrandr >= 1.5" \
xscrnsaver
# check if we need libxdg-basedir
ifeq (,$(findstring STATIC_CONFIG,$(CFLAGS)))
pkg_config_packs += libxdg-basedir
else
ifneq (,$(findstring STATIC_CONFIG,$(CFLAGS)))
$(warning STATIC_CONFIG is deprecated behavior. It will get removed in future releases)
endif

View File

@ -5,10 +5,6 @@
#include <glib.h>
#include <stdio.h>
#include <string.h>
#ifndef STATIC_CONFIG
#include <basedir.h>
#include <basedir_fs.h>
#endif
#include "rules.h" // put before config.h to fix missing include
#include "config.h"
@ -88,15 +84,35 @@ static enum urgency ini_get_urgency(const char *section, const char *key, const
return ret;
}
static FILE *xdg_config(const char *filename)
{
const gchar * const * systemdirs = g_get_system_config_dirs();
const gchar * userdir = g_get_user_config_dir();
FILE *f;
char *path;
path = g_strconcat(userdir, filename, NULL);
f = fopen(path, "r");
g_free(path);
for (const gchar * const *d = systemdirs;
!f && *d;
d++) {
path = g_strconcat(*d, filename, NULL);
f = fopen(path, "r");
g_free(path);
}
return f;
}
void load_settings(char *cmdline_config_path)
{
#ifndef STATIC_CONFIG
xdgHandle xdg;
FILE *config_file = NULL;
xdgInitHandle(&xdg);
if (cmdline_config_path) {
if (0 == strcmp(cmdline_config_path, "-")) {
config_file = stdin;
@ -104,21 +120,23 @@ void load_settings(char *cmdline_config_path)
config_file = fopen(cmdline_config_path, "r");
}
if(!config_file) {
if (!config_file) {
DIE("Cannot find config file: '%s'", cmdline_config_path);
}
}
if (!config_file) {
config_file = xdgConfigOpen("dunst/dunstrc", "r", &xdg);
config_file = xdg_config("/dunst/dunstrc");
}
if (!config_file) {
/* Fall back to just "dunstrc", which was used before 2013-06-23
* (before v0.2). */
config_file = xdgConfigOpen("dunstrc", "r", &xdg);
config_file = xdg_config("/dunstrc");
}
if (!config_file) {
LOG_W("No dunstrc found.");
xdgWipeHandle(&xdg);
}
}
load_ini_file(config_file);
@ -788,7 +806,6 @@ void load_settings(char *cmdline_config_path)
if (config_file) {
fclose(config_file);
free_ini();
xdgWipeHandle(&xdg);
}
#endif
}