config: add include_one directive for override-safe config includes#9017
Open
rajj28 wants to merge 1 commit intoswaywm:masterfrom
Open
config: add include_one directive for override-safe config includes#9017rajj28 wants to merge 1 commit intoswaywm:masterfrom
rajj28 wants to merge 1 commit intoswaywm:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new configuration directive called
include_oneto sway.The directive allows multiple include globs to be processed left-to-right,
including all files from the first glob and skipping files from subsequent
globs whose basenames were already included earlier. This makes it possible
to layer configuration directories cleanly without duplicate overrides.
Motivation
Sway (and i3) support including partial configuration files from directories,
which is commonly used to layer system-wide defaults and user overrides.
For example (Regolith use case):
include /usr/share/regolith/sway/config.d/*
include $HOME/.config/regolith2/sway/config.d/*
In practice, these directories often overlap, and the same filenames may
exist in both locations. While ordering helps, there is no way to express
"include system defaults unless the user already provided an override".
This PR introduces a new directive to solve that problem explicitly.
New directive:
include_oneinclude_one [ ...]
Behavior:
(filename without path) has not already been included.
includecommand.Example:
include_one $HOME/.config/regolith2/sway/config.d/*
/usr/share/regolith/sway/config.d/*
If both directories contain a file named
70_bar, the version from theuser directory is included and the system one is skipped.
Implementation details
includebehavior is unchanged.behavior on allocation failure.
includedirective.Notes
This change is isolated to configuration parsing and does not affect compositor
or wlroots internals. It was implemented and built against sway 1.9 using Meson;
rebasing to newer versions should only require minor mechanical adjustments due
to config code refactors.
Status
So if the user has ~/.config/regolith2/sway/config.d/70_bar, the system-wide /usr/share/regolith/sway/config.d/70_bar will be skipped, allowing user overrides.
This change was implemented as part of a qualification task and is submitted
for review and discussion.