Skip to content

About

lightweight service written in c++ which periodically checks git in specified folders and pushes new changes

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

configsync

A small C++ daemon that auto-pushes config changes to git. It watches a list of local git repos, checks every interval for changes, and if any are found runs git add -A → git commit → git push.

The binary is statically linked, so the only runtime dependency is git itself.

Build

Requirements: a C++23 compiler and CMake.

  • Arch: sudo pacman -S base-devel cmake
  • Debian/Ubuntu: sudo apt install build-essential cmake
git clone <repo-url> configsync
cd configsync
cmake -B build && cmake --build build

The binary is at build/configsync.

Configuration

The daemon reads ~/.config/configsync/config.toml:

interval = "5m"                       # also: 30s, 1h, 2d, or a plain int = seconds
commit_message = "auto: config sync {timestamp}"
push = true
user_name = "nico"                    # optional; passed via git -c, else gitconfig
user_email = "nico@example.com"       # optional
repos = [
  { path = "~/.config/fish" },
  { path = "~/dotfiles" },
]
Key Required Default Notes
interval yes — plain int = seconds, or a number with s/m/h/d
commit_message no "auto: config sync {timestamp}" {timestamp} is replaced with the current time, e.g. 2026-08-23 14:05
push no true if false, commits stay local
user_name / user_email no gitconfig commit identity, passed via git -c when set
repos yes — array of { path = "..." }; ~ is expanded; each folder must be its own git repo

The file is re-read every cycle, so it can be edited live without a restart. A malformed file logs an error and the last good config keeps being used.

Running

Foreground

./build/configsync

Optionally pass a config path to override the default:

./build/configsync /path/to/some/config.toml

Logs go to stderr as [YYYY-MM-DD HH:MM:SS] LEVEL: message. Ctrl-C (SIGINT) or SIGTERM stops the daemon cleanly.

As a per-user systemd service

cmake --install build --prefix "$HOME/.local"
install -Dm644 systemd/configsync.service "$HOME/.config/systemd/user/configsync.service"
systemctl --user daemon-reload
systemctl --user enable --now configsync

Useful commands:

systemctl --user status configsync
journalctl --user -u configsync -f     # follow the logs
systemctl --user stop configsync

To keep the service running after you log out (so it actually syncs in the background), enable lingering for your user:

sudo loginctl enable-linger "$USER"

Behavior

For each repo in the config, every interval:

  1. git status --porcelain — empty output means nothing changed; the repo is skipped (one cheap subprocess, no file hashing).
  2. git add -A — -A so deletions get synced too.
  3. git commit -m "<message>" with {timestamp} substituted.
  4. If push = true: git push. On failure an ERROR is logged and the daemon continues — there is no automatic pull/rebase; the commit stays in local history and the push is retried implicitly on the next cycle.

A path that is missing or not a git repo logs a WARN and is skipped; the daemon keeps running.

Project layout

configsync/
├── CMakeLists.txt
├── src/
│   ├── main.cpp          # main loop, signal handling, logging
│   ├── config.cpp/.hpp   # TOML parsing, interval parsing, ~ expansion
│   └── git.cpp/.hpp      # git command runner (fork/exec, captures stdout)
├── .vscode/
│   └── tasks.json        # overseer.nvim / VS Code build task
├── third_party/toml.hpp  # toml++ single header (MIT)
└── systemd/configsync.service

About

lightweight service written in c++ which periodically checks git in specified folders and pushes new changes

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages