From adb8051729dd5c2b84d59899efc2c7bdd4b5a0dc Mon Sep 17 00:00:00 2001 From: Eivind Siqveland Larsen Date: Sat, 25 May 2024 21:39:49 +0200 Subject: [PATCH] hints --- example/main.go | 7 +++++-- notification.go | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/example/main.go b/example/main.go index 9ed036e..fd5c7cb 100644 --- a/example/main.go +++ b/example/main.go @@ -7,8 +7,9 @@ import ( "sync" "time" - "github.com/esiqveland/notify" "github.com/godbus/dbus/v5" + + "github.com/esiqveland/notify" ) func main() { @@ -29,7 +30,7 @@ func main() { } // Basic usage - sndVariant := notify.SoundWithName( + sndVariant := notify.HintSoundWithName( //"message-new-instant", "trash-empty", ) @@ -51,6 +52,8 @@ func main() { }, ExpireTimeout: time.Second * 5, } + n.SetUrgency(notify.UrgencyCritical) + // Ship it! createdID, err := notify.SendNotification(conn, n) diff --git a/notification.go b/notification.go index 175bf63..0b0a8c7 100644 --- a/notification.go +++ b/notification.go @@ -76,13 +76,15 @@ type Notification struct { ExpireTimeout time.Duration } -func (n *Notification) SetUrgency(urgency Urgency) *Notification { +func (n *Notification) SetUrgency(urgency Urgency) { + n.AddHint(HintUrgency(urgency)) +} + +func (n *Notification) AddHint(hint Hint) { if n.Hints == nil { n.Hints = map[string]dbus.Variant{} } - h := HintUrgency(urgency) - n.Hints[h.ID] = h.Variant - return n + n.Hints[hint.ID] = hint.Variant } // ExpireTimeoutSetByNotificationServer used as ExpireTimeout to leave expiration up to the notification server.