desktopnotify

package
v1.34.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package desktopnotify posts native desktop notifications from the daemon. On Linux it calls org.freedesktop.Notifications on the session bus using the godbus dependency lerd already ships; other platforms are no-ops for now.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppInstalled

func AppInstalled() bool

AppInstalled reports whether the Lerd desktop app is registered as the lerd:// scheme handler, so callers can prefer it over a browser.

func Emit

func Emit(req Request) (uint32, error)

Emit shows a native notification and returns the daemon-assigned id.

func IconPath

func IconPath() string

IconPath materializes the bundled lerd icon to a stable cache path and returns its absolute path. Notification daemons that ignore themed names still show the logo this way. Returns "" on failure, letting the daemon draw its default.

func OpenApp

func OpenApp(route string) error

OpenApp focuses (or launches) the desktop app at the given dashboard route via its lerd:// scheme. Start, not Run: xdg-open can outlive the handoff, which would block `lerd dashboard` and freeze the tray's Dashboard item behind it.

func Supported

func Supported() bool

Supported reports whether native notifications can be delivered on this host. True when a daemon already owns the well-known name (GNOME, KDE, which run it as part of the session) or when the name is D-Bus activatable (mako, dunst, xfce4-notifyd, which auto-start on the first Notify). False on a headless host with no session bus and no daemon, so callers fall back to the browser sink.

Types

type Progress added in v1.34.0

type Progress interface {
	// Step replaces the body with what is happening now.
	Step(text string)
	// Percent moves the bar. A total of zero leaves it alone, which is what the
	// stretch before the unit count is known looks like.
	Percent(done, total int)
	// Close takes the popup down.
	Close()
}

Progress reports a long operation to the desktop while it runs. Off Linux, and on a session with no notification daemon, every method is a no-op so the operation still runs rather than being refused because nothing can draw it.

func StartProgress added in v1.34.0

func StartProgress(summary, body string) Progress

StartProgress opens a notification that is rewritten in place as the work proceeds. It goes over the session bus lerd already speaks for every other notification, so a progress window costs no tool the desktop may not have.

The "value" hint is the freedesktop convention for a progress bar; a daemon that does not render one still shows the summary and the step, which is the part that says the click did something.

type Request

type Request struct {
	AppName string
	Icon    string // themed icon name or absolute path; "" shows the daemon default
	Summary string
	Body    string
	Urgency Urgency
	Route   string // dashboard route to open on click; "" makes the popup inert
}

Request is a single native notification to show.

type Urgency

type Urgency byte

Urgency maps to the org.freedesktop.Notifications "urgency" hint byte.

const (
	UrgencyLow      Urgency = 0
	UrgencyNormal   Urgency = 1
	UrgencyCritical Urgency = 2
)

func UrgencyFromString

func UrgencyFromString(s string) Urgency

UrgencyFromString maps lerd's notification urgency strings to the DBus hint. Unknown or empty values are Normal, matching the Web Push default.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL