package main import ( "fmt" "time" dbus "github.com/godbus/dbus/v5" ) type Notification struct { Time time.Time AppName string Summary string Body string } // https://specifications.freedesktop.org/notification-spec/latest/protocol.html func NewNotification(message *dbus.Message) Notification { return Notification{ Time: time.Now(), AppName: fmt.Sprintf("%v", message.Body[0]), Summary: fmt.Sprintf("%v", message.Body[3]), Body: fmt.Sprintf("%v", message.Body[4]), } } func (n Notification) String() string { return fmt.Sprintf("%s\n%s %s\n%s\n\n", datetimeStyle.Render(n.Time.Format(DATETIME_FORMAT)), getAppNameStyle(n.AppName).Render(n.AppName), summaryStyle.Render(n.Summary), bodyStyle.Render(n.Body), ) }