// Copyright (C) 2026 Danilo M. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. package notify import ( "errors" "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 }