blob: a42a14b55cfa9019854217c6beeffb79ab312e90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// 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
}
|