Skip to content

notifications

Go Reference

Implements the freedesktop.org Desktop Notifications Specification — the service side of org.freedesktop.Notifications, the D-Bus interface desktop applications call (through notify-send, libnotify, GLib.Notification, …) to post notification bubbles. It decodes those Notify calls and hands them to a renderer such as the go-widgets Toast. Pure Go, CGO_ENABLED=0.

  • Claim the well-known name org.freedesktop.Notifications on the session bus.
  • Decode Notify / CloseNotification / GetCapabilities / GetServerInformation calls.
  • Drive a toast daemon from your render loop; emit NotificationClosed / ActionInvoked signals back.

Install

go get github.com/go-freedesktop/notifications

Usage

conn, _ := dbus.ConnectSessionBus()
daemon := toast.NewDaemon(nil, toolkit.DefaultDark(), myIconLookup)
server := notifications.NewServer(conn, daemon)
daemon.SetEmitter(server)
if err := server.Export(); err != nil { // claims org.freedesktop.Notifications
    log.Fatal(err)
}
// ... call daemon.Tick() from your render loop and draw daemon.Toasts().

The full API is on pkg.go.dev. Source: github.com/go-freedesktop/notifications.