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 #997

Merged
merged 15 commits into from
Feb 23, 2022
Merged

Conversation

fwsmit
Copy link
Member

@fwsmit fwsmit commented Dec 6, 2021

This PR introduces support for drop-ins--those files (or snippets) usually residing in a *.d directory to override (some or all settings of) the main/base config in the parent directory.

Dial back a little on the space requirement of the prefix for messages
of levels "debug", "error" and "critical". The prefix now only
includes the function name, padded to 16 characters so as to make for
better vertical alignment, and the line number in the source file.

Additionally updated feature test macro to make this work with recent
enough versions of clang as well.

config.mk: Disable warnings about empty __VA_ARGS__

Since compilation is done with '-std=gnu99' and token pasting of ',' and
'__VA_ARGS__' is a GNU extension which also works with clang (>=6) this
warning should be safe to disable, see also the changes to log.h above.
The CI did not complain in my local tests.

Only clang threw this warning before and only to inform that it is
indeed a GNU extension, despite using the same '-std=gnu99'.
This should not mask genuine errors when __VA_ARGS__ must not be empty,
i.e. usage without token pasting it with ',', since those should be
errors that lead to unsuccessful compilation, anyway.
This is basically a proof of concept, so not much official
documentation just yet. Include syntax is a little more strict. The
keyword is "@include", which is borrowed from doxygen. There MUST not be
any blanks before the "@", like in C.

Some reasoning for these preliminary decisions:
Includes should stand out and thus should get some kind of special
character prefix, but since '#' is already taken, they could be mistaken
for comments, especially with syntax highlighting enabled. Using all
capitol letters and not allowing spaces in front also serves to make
them more distinguishable.

Drive-by fix: Sections surrounded by spaces are no longer possible.
Also some refinements to the FILES section.
Refactoring for necessarily added complexity and push file handling
into 'load_settings()', because otherwise there would be virtually no
limit on how many files could be open at the same time, while we only
read them sequentially, anyway.
Also reverted stripping of section names.
A more thorough check of what constitutes as *useable* and readable
file.
fwsmit and others added 4 commits December 6, 2021 18:04
Moved from settings and renamed, a small wrapper around
`is_readable_file()` and `fopen()`.
Do away with the 'G_*' prefix of macros because it is misleading. The
original intention was to make clear that they are derived from Glib
functions but instead they might be mistaken for *actual* Glib content.

Also added some more documentation for clarity.
Also fixed a double free issue with the provided path parameter.

Removed leftover prototype of fopen_conf().
@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2021

Codecov Report

Merging #997 (8c4fb45) into master (2368e4a) will increase coverage by 0.76%.
The diff coverage is 71.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #997      +/-   ##
==========================================
+ Coverage   60.12%   60.88%   +0.76%     
==========================================
  Files          44       44              
  Lines        6791     6877      +86     
==========================================
+ Hits         4083     4187     +104     
+ Misses       2708     2690      -18     
Flag Coverage Δ
unittests 60.88% <71.51%> (+0.76%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/icon-lookup.c 85.85% <ø> (-0.75%) ⬇️
src/icon.c 74.19% <ø> (-0.33%) ⬇️
src/option_parser.c 80.10% <ø> (ø)
test/queues.c 98.86% <ø> (ø)
src/settings.c 48.64% <35.71%> (-14.77%) ⬇️
src/utils.c 88.93% <92.00%> (+0.38%) ⬆️
src/ini.c 78.78% <100.00%> (ø)
test/draw.c 100.00% <100.00%> (ø)
test/helpers.c 95.83% <100.00%> (+6.94%) ⬆️
test/test.c 93.75% <100.00%> (+0.20%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d1c73fa...8c4fb45. Read the comment docs.

@fwsmit fwsmit changed the title Dunstrc d fwsmit Add support for config drop-ins Dec 6, 2021
@fwsmit fwsmit force-pushed the dunstrc_d_fwsmit branch 2 times, most recently from f87a6a8 to 6189d01 Compare December 24, 2021 17:05
@fwsmit
Copy link
Member Author

fwsmit commented Feb 23, 2022

Merged it.

@Kranzes
Copy link

Kranzes commented Jan 25, 2024

It seems that drop-ins don't work when using --config to point to the dunstrc? (the drop-ins are inside dunstrc.d which is next to the dunstrc file).

@fwsmit
Copy link
Member Author

fwsmit commented Jan 27, 2024

Yeah, that could be. If you have a use case for that to be different, please open an issue about it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants