pub enum DTScope {
General,
App,
Dropin,
}Expand description
Scope of a group, used to resolve priority of possibly duplicated items, to ensure every target path is pointed from only one source item.
The order of priority is:
Within the same scope, the first defined group in the config file for DT has the highest priority, later defined groups have lower priorities.
Groups without a given scope are treated as of General scope.
§Example
When you want to populate all your config files for apps that follows the XDG standard, you might write a config file for DT that looks like this:
[[local]]
name = "xdg_config_home"
base = "/path/to/your/xdg/config/directory"
sources = ["*"]
target = "~/.config"Let’s say after some weeks or months, you have decided to also include
/usr/share/fontconfig/conf.avail/11-lcdfilter-default.conf to your
fontconfig directory, which is ~/.config/fontconfig/conf.d, you do so by
adding another [[local]] group into your config file for DT:
[[local]]
name = "fontconfig-system"
base = "/usr/share/fontconfig/conf.avail"
sources = ["11-lcdfilter-default.conf"]
target = "~/.config/fontconfig/conf.d"A problem arises when you also maintain a version of
11-lcdfilter-default.conf of your own: If DT syncs the
fontconfig-system group last, the resulting config file in your
$XDG_CONFIG_HOME is the system version; While if DT syncs the
xdg_config_home group last, that file ended up being your previously
maintained version.
Actually, DT is quite predictable: it only performs operations in the
order defined in the config file for your groups. By defining the
fontconfig-system group last, you can completely avoid the ambiguity
above.
However, since the config file was written by you, a human, and humans are
notorious for making mistakes, it would be great if DT could always know
what to do when duplicated items are discovered in the config file.
Instead of putting the groups with higher priority at the end of your
config file, you could simply define scopes in their definitions:
[[local]]
name = "fontconfig-system"
scope = "Dropin"
...
[[local]]
name = "xdg_config_home"
scope = "General"
...Now, with the scope being set, DT will first remove the source item
11-lcdfilter-default.conf (if it exists) from group xdg_config_home,
then perform its syncing process.
This is also useful with dt-cli’s -l|--local-name option, which gives
you more granular control over how items are synced.
Variants§
General
The scope with lowest priority, this is the default scope, recommended for directories that contains config files for many un-categorized applications.
App
Dropin
The scope for drop-in replacements, it has the highest priority.