Dotdrop for dotfiles
I use two computers: a desktop and a laptop.
Both computers should always be synchronized. Syncthing takes care of my files (music, images, documents), but the configurations should also always be the same.
Many Linux programs store their settings in the hidden .config directory. However, I don't want this folder to be completely synchronized, just individual files ... so called dotfiles.
This is where dotdrop comes in.
Dotdrop is a dotfiles manager that provides efficient ways to manage your dotfiles. It is especially powerful when it comes to managing those across different hosts. The idea of dotdrop is to have the abilit``y to store each dotfile only once and deploy them with different content on different hosts/setups.
Put simply, dotdrop makes a copy of the file in a specified directory and also takes care the permissions. This directory can then be synchronized between two computers using git (or any other tool).
It uses the hostname as the profile. This means that the configuration can also be used to specify which computer the file should be installed on.
Add a file to dropdrop
dotdrop import FILENAME
This adds to the profile of the current computer. However, a different profile (usually the host name of the other computer) can also be specified during import.
dotdrop import --profile=HOSTNAME FILENAME
The config file can be put in ~/.config/dotdrop/, among other places. However, since I also push other things to git (Codeberg) via this directory, I decided to use ~/.dotdrop.
I also use two configuration files: one for user files and one for system files.
dotdrop import --cfg=~/.dotdrop/config-user.yaml FILENAME
or
dotdrop import --cfg=~/.dotdrop/config-root.yaml FILENAME
Remove a file to dropdrop:
Also very simple. Just go to the correct folder and
dotdrop remove FILENAME
Installing a file
Once the file has been assigned to the corresponding profile in the configuration file, it is installed on the computer using the following command. Before doing so, it is of course advisable to execute a git pull to ensure that the current file has been loaded into the dotdrop folder.
dotdrop --cfg=~/.dotdrop/config-user.yaml install
Or for systemfiles:
sudo dotdrop --cfg=~/.dotdrop/config-root.yaml install
Customisation
The great thing about dotdrop is that it is very easy to integrate into your own scripts. For example, I did not find that the file is always automatically added to all profiles during import. Perhaps this is possible by default, but I did not find anything about it in the documentation.
So I simply execute the command twice with this script:
#!/bin/bash
CONF="~/.dotdrop/config-user.yaml"
PROFILES=(
"hostname1"
"hostname2"
)
for prof in "${PROFILES[@]}"; do
dotdrop import --cfg=$CONF --profile=$prof $1
done
dotdrop --cfg=$CONF profiles
Conclusion
There are similar tools to dotdrop. The best example is chezmoi, which I really enjoyed using on openSUSE. However, this is not included with Debian. It was a bit of a shame at first, but now I like the simplicity of dotdrop.