Skip to content

Commit

Permalink
hints
Browse files Browse the repository at this point in the history
  • Loading branch information
esiqveland committed May 25, 2024
1 parent aab4d68 commit adb8051
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"sync"
"time"

"github.com/esiqveland/notify"
"github.com/godbus/dbus/v5"

"github.com/esiqveland/notify"
)

func main() {
Expand All @@ -29,7 +30,7 @@ func main() {
}

// Basic usage
sndVariant := notify.SoundWithName(
sndVariant := notify.HintSoundWithName(
//"message-new-instant",
"trash-empty",
)
Expand All @@ -51,6 +52,8 @@ func main() {
},
ExpireTimeout: time.Second * 5,
}
n.SetUrgency(notify.UrgencyCritical)


// Ship it!
createdID, err := notify.SendNotification(conn, n)
Expand Down
10 changes: 6 additions & 4 deletions notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit adb8051

Please sign in to comment.