diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-19 09:16:20 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-19 09:16:20 +0200 |
| commit | 20f1b7bab5811f2ca4d2b0af93a0318adaf2fcac (patch) | |
| tree | c2b575d13b9bd731d54e916e078d71e935f01ddb | |
| parent | 73d7aff4248a5ab05cec55dbd7feb0d17b97c1df (diff) | |
| download | notifyd-20f1b7bab5811f2ca4d2b0af93a0318adaf2fcac.tar.gz notifyd-20f1b7bab5811f2ca4d2b0af93a0318adaf2fcac.zip | |
feat(notifyctl): add reload, re-reading the config file
The daemon also reads the file at start. Armed timers keep their lifetime;
the next notification gets the new default.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| -rw-r--r-- | cmd/notifyctl/main.go | 3 | ||||
| -rw-r--r-- | internal/notify/control.go | 7 | ||||
| -rw-r--r-- | internal/notify/service.go | 11 |
3 files changed, 21 insertions, 0 deletions
diff --git a/cmd/notifyctl/main.go b/cmd/notifyctl/main.go index e0875e7..6de678e 100644 --- a/cmd/notifyctl/main.go +++ b/cmd/notifyctl/main.go @@ -30,6 +30,7 @@ func usage() { close-all dismiss every notification action <id> <key> invoke an action on a live notification clear-history empty the history ring + reload re-read ~/.config/notifyd/config.json `, filepath.Base(os.Args[0])) os.Exit(2) } @@ -69,6 +70,8 @@ func main() { callControl("InvokeAction", id, os.Args[3]) case "clear-history": callControl("ClearHistory") + case "reload": + callControl("Reload") default: usage() } diff --git a/internal/notify/control.go b/internal/notify/control.go index a42a14b..85c4d74 100644 --- a/internal/notify/control.go +++ b/internal/notify/control.go @@ -53,3 +53,10 @@ func (c *control) ClearHistory() *dbus.Error { c.svc.store.ClearHistory() return nil } + +// Reload re-reads ~/.config/notifyd/config.json. The settings page calls it +// after a save; a bad file is logged and read as defaults, never an error. +func (c *control) Reload() *dbus.Error { + c.svc.reload() + return nil +} diff --git a/internal/notify/service.go b/internal/notify/service.go index b29a783..1b1c89b 100644 --- a/internal/notify/service.go +++ b/internal/notify/service.go @@ -77,10 +77,21 @@ func (s *Service) Start() error { if err := os.RemoveAll(ImagesDir(s.dir)); err != nil { log.Printf("notifyd: clear images: %v", err) } + s.reload() s.store.Reset() return nil } +// reload re-reads the config file and applies it. Timers already armed keep +// their old lifetime; the next notification gets the new one. +func (s *Service) reload() { + c := LoadConfig(ConfigPath()) + s.mu.Lock() + s.cfg = c + s.mu.Unlock() + s.store.SetCaps(c.LiveCap, c.HistoryCap) +} + func (s *Service) emitClosed(id, reason uint32) { s.conn.Emit(dbus.ObjectPath(objPath), iface+".NotificationClosed", id, reason) } |
