If you’re a KDE user who wants to keep your desktop configuration under version control, you’ve probably discovered that KDE’s configuration files can be quite challenging to manage with traditional dotfile tools. KDE stores settings in complex INI files that frequently change, contain system-specific data, and include sections you may not want to track. This is where Chezmoi Modify Manager becomes useful when using the Chezmoi dotfile manager.
The Problem with KDE Configuration Files
KDE applications like Kate, Dolphin, and KWin store their settings in INI-style configuration files. These files often contain:
- Volatile sections that change frequently (like window positions, recent files)
- System-specific data (like file dialog sizes, screen configurations)
- Mixed content where you only want to track specific settings
Things have improved recently in that respect; however, some KDE INI files still mix those configurations.
Managing these files directly with Chezmoi would result in noisy diffs and configurations that don’t work well across different machines.
Enter Chezmoi Modify Manager
Chezmoi Modify Manager acts as a configurable filter between your actual config files and your Chezmoi repository. It allows you to:
- Ignore entire sections or specific keys
- Set specific values while ignoring everything else
- Use regex patterns for flexible matching
- Transform values during processing
The tool works by creating “modify scripts” that tell Chezmoi how to process each configuration file.
Quoting from the official documentation:
For each settings file you want to manage with
chezmoi_modify_managerthere will be two files in your chezmoi source directory:
modify_<config file>ormodify_<config file>.tmpl, e.g.modify_private_kdeglobals.tmpl
This is the modify script/configuration file that callschezmoi_modify_manager. It contains the directives describing what to ignore.<config file>.src.ini, e.g.private_kdeglobals.src.ini
This is the source state of the INI file.The
modify_script is responsible for generating the new state of the file given the current state in your home directory. Themodify_script is set up to usechezmoi_modify_manageras an interpreter to do so.chezmoi_modify_managerwill read the modify script to read configuration and the.src.inifile and by default will apply that file exactly (ignoring blank lines and comments).
Note that this is based on the Chezmoi mechanism of “modifying scripts”, allowing you to manage only some parts of files.
Thus, the integration with Chezmoi is based on these mechanisms:
- Source files (
.src.ini) contain your desired configuration - Modify scripts (starting with
modify_) define filtering rules - Chezmoi applies the modifications when deploying configs
- The .chezmoiignore file ensures source files aren’t directly copied
The file name after “modify_” and the file name of the “.src.ini” must follow the naming conventions of Chezmoi.
Your .chezmoiignore must include:
|
1 2 |
**/*.src.ini |
This prevents the source files from being deployed directly, letting Chezmoi Modify Manager handle the processing.
So, let’s see how to use that.
Real-World Examples
You can use the “chezmoi_modify_manager” command line to create the proper files.
Let’s look at how this works in practice with actual KDE configurations, based on my dotfiles (so I have already created these files):
KWin Configuration (kwinrc)
The file “modify_private_kwinrc”:
|
1 2 3 4 5 6 7 8 9 |
#!/usr/bin/env chezmoi_modify_manager source auto ignore section "$Version" ignore section "Desktops" ignore regex "Tiling.*" ".*" ignore section "Xwayland" |
This script ensures only the relevant window manager settings are tracked (the file “private_kwinrc.src.ini”):
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[Effect-cube] CubeFaceDisplacement=126 DistanceFactor=1.82 [Effect-magiclamp] AnimationDuration=400 [Plugins] cubeEnabled=true magiclampEnabled=true squashEnabled=false [TabBox] DesktopMode=0 HighlightWindows=false LayoutName=compact |
Global Shortcuts (kglobalshortcutsrc)
The names of the files are using the same convention already shown before.
For keyboard shortcuts, you might want to ignore certain dynamic sections:
|
1 2 3 4 5 6 |
#!/usr/bin/env chezmoi_modify_manager source auto ignore section "ActivityManager" |
This keeps your custom shortcuts while filtering out activity-specific bindings that may not be relevant across systems. The file “private_kglobalshortcutsrc.src.ini” is not shown because it’s quite huge.
Font Configuration (kdeglobals)
Sometimes you only want to track a single setting:
|
1 2 3 4 5 6 7 |
#!/usr/bin/env chezmoi_modify_manager source auto set "General" "fixed" "Hack Nerd Font,10,-1,5,400,0,0,0,0,0,0,0,0,0,0,1" separator="=" ignore regex ".*" ".*" |
This results in a clean config that only tracks the terminal font:
|
1 2 3 |
[General] fixed=Hack Nerd Font,10,-1,5,400,0,0,0,0,0,0,0,0,0,0,1 |
Kate Editor Configuration
For Kate, you might want to ignore volatile sections while keeping your editor preferences:
|
1 2 3 4 5 6 7 8 9 10 |
#!/usr/bin/env chezmoi_modify_manager source auto ignore section "KFileDialog Settings" ignore section "FileDialogSize" ignore section "KTextEditor::Search" ignore section "MainWindow" ignore regex "Kate Print Settings.*" ".*" |
Again, the “.src.ini” file is not shown.
Benefits
- Clean diffs: Only track settings you care about
- Portable configs: No system-specific clutter
- Selective tracking: Include only relevant sections
Drawbacks
In general, setting the files initially takes much more time: you need to understand what to include/exclude in the “modify_” scripts and properly craft the “.src.ini” files accordingly. Moreover, some Chezmoi mechanisms, such as “merge,” will not function. Therefore, updating the files requires employing alternative techniques, as outlined in the next blog post. Finally, besides “chezmoi”, you need to install an additional program “chezmoi_modify_manager”.