From bcf15590f9e43f2d8978cf7cccfbdf3bb66e376f Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 15 Sep 2026 13:53:34 +0200 Subject: feat: add the control interface and notifyctl The private interface carries what the spec cannot: close-all, invoke action and clear history. notifyctl reads the published files for list and history, because the files are the interface, and uses D-Bus only for the mutations. --- internal/notify/control.go | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'internal/notify/control.go') diff --git a/internal/notify/control.go b/internal/notify/control.go index 4783711..a42a14b 100644 --- a/internal/notify/control.go +++ b/internal/notify/control.go @@ -11,14 +11,45 @@ package notify -import "github.com/godbus/dbus/v5" +import ( + "errors" -// control is the private interface notifyctl drives. + "github.com/godbus/dbus/v5" +) + +// control is the private interface notifyctl drives. It exists because the +// freedesktop spec has no close-all, no way to invoke an action, and no +// history to clear. type control struct { svc *Service } +// CloseAll dismisses every live notification, reason 2. func (c *control) CloseAll() *dbus.Error { c.svc.store.DismissAll() return nil } + +// Dismiss closes one live notification, reason 2, which is what a click on the +// X means. +func (c *control) Dismiss(id uint32) *dbus.Error { + c.svc.stopTimer(id) + c.svc.store.Dismiss(id, 2) + return nil +} + +// InvokeAction emits ActionInvoked for a live notification. An inert entry has +// no client left, so it is an error rather than a silent no-op. +func (c *control) InvokeAction(id uint32, key string) *dbus.Error { + if !c.svc.store.Actionable(id) { + return dbus.MakeFailedError(errors.New("notification is no longer live")) + } + c.svc.conn.Emit(dbus.ObjectPath(objPath), iface+".ActionInvoked", id, key) + return nil +} + +// ClearHistory empties the history ring. +func (c *control) ClearHistory() *dbus.Error { + c.svc.store.ClearHistory() + return nil +} -- cgit v1.2.3