Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for config drop-ins (rudimentary includes as a bonus) #933

Closed
wants to merge 9 commits into from
2 changes: 1 addition & 1 deletion config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ENABLE_WAYLAND= -DENABLE_WAYLAND
endif

# flags
DEFAULT_CPPFLAGS = -D_DEFAULT_SOURCE -DVERSION=\"${VERSION}\" -DSYSCONFDIR=\"${SYSCONFDIR}\"
DEFAULT_CPPFLAGS = -Wno-gnu-zero-variadic-macro-arguments -D_DEFAULT_SOURCE -DVERSION=\"${VERSION}\" -DSYSCONFDIR=\"${SYSCONFDIR}\"
fwsmit marked this conversation as resolved.
Show resolved Hide resolved
DEFAULT_CFLAGS = -g -std=gnu99 -pedantic -Wall -Wno-overlength-strings -Os ${ENABLE_WAYLAND} ${EXTRA_CFLAGS}
DEFAULT_LDFLAGS = -lm -lrt

Expand Down
51 changes: 35 additions & 16 deletions docs/dunst.1.pod
Original file line number Diff line number Diff line change
Expand Up @@ -100,38 +100,57 @@ missed notifications after returning to the computer.
=head1 FILES

These are the base directories dunst searches for configuration files in
descending order of imortance:
I<descending order of imortance>:

=over 4
=over 8

=item C<$XDG_CONFIG_HOME>

This is the most important directory. (C<$HOME/.config> if unset or empty)

$XDG_CONFIG_HOME ($HOME/.config if unset or empty)
=item C<$XDG_CONFIG_DIRS>

$XDG_CONFIG_DIRS (:-separated list of base directories in descending order
of importance; ##SYSCONFDIR## if unset or empty)
This, like C<$PATH> for instance, is a :-separated list of base directories
in I<descending order of importance>.
(F<##SYSCONFDIR##> if unset or empty)

=back

Dunst will search these directories for the following relative path:
Dunst will search these directories for the following relative file paths:

=over 4
=over 8

dunst/dunstrc
=item F<dunst/dunstrc>
WhitePeter marked this conversation as resolved.
Show resolved Hide resolved

=back
This is the base config and as such the least important in a particular base
directory.

All settings from all files get applied. Settings in more important files
override those in less important ones. Settings not present in more imortant
files are taken from a less important one or from the internal defaults if they
are not found in any file.
=item F<dunst/dunstrc.d/*.conf>

=over 4
These are "drop-ins" (mind the ".d" suffix of the directory).
They are more important than the base dunstrc in the parent directory, as they
are considered to be small snippets to override settings.
The last in lexical order is the most important one, so you can easily change
the order by renaming them.
A common approach to naming drop-ins is to prefix them with numbers, i.e.:

=item This is where the default (least important) config file is located:
00-least-important.conf
01-foo.conf
20-bar.conf
99-most-important.conf

##SYSCONFDIR##/dunst/dunstrc
The only requirements are that the name of the file must have the correct
suffix and the first non-blank line that is not a comment must be a section or
rule identifier.

=back

All settings from all files get applied. Settings in more important files
override those in less important ones.
Settings not present in more imortant files get their value from a less
important one or from the internal defaults if respective key is not found in
any file.

=head1 AUTHORS

Written by Sascha Kruse <[email protected]>
Expand Down
5 changes: 0 additions & 5 deletions src/icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
#include "utils.h"
#include "icon-lookup.h"

static bool is_readable_file(const char *filename)
{
return (access(filename, R_OK) != -1);
}

/**
* Reassemble the data parts of a GdkPixbuf into a cairo_surface_t's data field.
*
Expand Down
3 changes: 2 additions & 1 deletion src/ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "utils.h"
#include "log.h"
#include "settings.h"

struct section *get_section(struct ini *ini, const char *name)
{
Expand Down Expand Up @@ -107,7 +108,7 @@ struct ini *load_ini_file(FILE *fp)
*end = '\0';

g_free(current_section);
current_section = (g_strdup(start + 1));
current_section = g_strdup(start + 1);
continue;
}

Expand Down
15 changes: 7 additions & 8 deletions src/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,23 @@
* @... are the arguments to above format string.
*
* This requires -Wno-gnu-zero-variadic-macro-arguments with clang
* because __VA_OPTS__ seems not to be officially supported yet.
* However, the result is the same with both gcc and clang.
* because of token pasting ',' and %__VA_ARGS__ being a GNU extension.
* However, the result is the same with both gcc and clang and since we are
* compiling with '-std=gnu99', this should be fine.
*/
#if __GNUC__ >= 8

#define MSG(format, ...) "[%s:%s:%04d] " format, __FILE__, __func__, __LINE__, ## __VA_ARGS__
#if __GNUC__ >= 8 || __clang_major__ >= 6
#define MSG(format, ...) "[%16s:%04d] " format, __func__, __LINE__, ## __VA_ARGS__
#endif

#ifdef MSG
// These should benefit from more context
#define LOG_E(...) g_error(MSG(__VA_ARGS__))
#define LOG_C(...) g_critical(MSG(__VA_ARGS__))
#define LOG_D(...) g_debug(MSG(__VA_ARGS__))

#else

#define LOG_E g_error
#define LOG_C g_critical
#define LOG_D g_debug

#endif

#define LOG_W g_warning
Expand Down
1 change: 0 additions & 1 deletion src/option_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ int string_parse_bool(const void *data, const char *s, void *ret)
return success;
}


int get_setting_id(const char *key, const char *section) {
int error_code = 0;
int partial_match_id = -1;
Expand Down
Loading