regolith-linux / sway-regolith

i3-compatible Wayland compositor
https://swaywm.org
MIT License
6 stars 2 forks source link

Added module include_one which fixes the issue of loading multiple configs #6

Open DeepanshuPratik opened 1 year ago

DeepanshuPratik commented 1 year ago

Sway configuration override

A configuration option that sway has (and i3 as well) is to include partial configuration files from directories. The issue being it first imports the global configuration, then the user configuration, which often overlaps. To avoid overlap, the user manually needs to delete the earlier default package and install the custom one.

To resolve this issue, I have created one config command called include_one, with the syntax: include_one path1 path2 path3 ... and as you keep including paths, the priority of the paths increases sequentially. Configurations with higher priorities having the same file name would be selected.

Example of usage of include_one command: include_one /usr/share/regolith/sway/config.d/* $HOME/.config/regolith2/sway/config.d/* Here if there is a config file in both the paths with the same name, then the config file of the path $HOME/.config/regolith2/sway/config.d/* will be getting priority and will be loaded.

Testing

To test this functionality, I created two config files with the same name in different directories. Both the config partials contained the same keybinding but with different functionality. I used the command include_one in the sway root config and supplied it as an argument to sway-regolith with this patch applied. As expected, the key binding mapped to the functionality specified in the config file with the higher priority.

DeepanshuPratik commented 1 year ago

I'm getting no more errors from file sway/commands/include_one.c (where I've made the changes). Valgrind log