1
0
Fork
You've already forked syncwhen
0
No description
  • Python 94.8%
  • Just 5.2%
2025年11月01日 09:36:53 -07:00
service service/systemd: enabled unbuffered python output 2025年11月01日 09:36:53 -07:00
config.toml.example add initial implementation 2025年10月27日 13:27:55 -07:00
justfile add initial implementation 2025年10月27日 13:27:55 -07:00
LICENSE add license 2025年10月27日 13:21:17 -07:00
main.py Stop caching dbus interface objects for systemd / manager 2025年10月30日 20:57:01 -07:00
README.md add initial implementation 2025年10月27日 13:27:55 -07:00

syncwhen

A daemon that conditionally controls syncthing.service based on system state (AC power, WiFi network, power profile). Uses D-Bus to monitor system changes and start/stop syncthing automatically based on configurable conditions.

Features

  • Conditional control: Only run syncthing when specific conditions are met (AND logic)
  • Interactive notifications: Override automatic decisions with action buttons
  • Modular design: Easy to add new conditions
  • Graceful degradation: Continues working if optional services unavailable

Dependencies

  • Python 3.11+ (for tomllib)
  • py3-dbus
  • py3-gobject
  • systemd

Or if you prefer:

$ just check-deps
OK!

Configuration

An example configuration is provided in config.toml.example. Copy it to:

$XDG_CONFIG_HOME/syncwhen/config.toml

(defaults to ~/.config/syncwhen/config.toml if XDG_CONFIG_HOME is not set)

Note: All enabled conditions must be satisfied for syncthing to run. If no conditions are enabled, syncthing runs unrestricted.

Installation

$ PREFIX=/usr DESTDIR="$pkgdir" just install

Enable the service:

$ systemctl --user daemon-reload
$ systemctl --user enable --now syncwhen.service

Design

  1. Monitors D-Bus for system state changes (AC power, WiFi, power profile)
  2. When any condition changes, evaluates all enabled conditions
  3. Starts or stops syncthing.service via systemd based on evaluation
  4. Shows notifications with override buttons when state changes
  5. Manual overrides persist until next condition change