Documentation
¶
Overview ¶
Package desktopnotify posts native desktop notifications from the daemon: org.freedesktop.Notifications over D-Bus on Linux, Windows toasts through PowerShell inside WSL, and nothing elsewhere for now.
Index ¶
Constants ¶
const ToastAppID = "sh.lerd.Lerd"
ToastAppID is the AppUserModelID lerd's toasts are posted under. Registering it in HKCU is what titles them "Lerd" with the logo; no app has to exist.
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 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.
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
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.
func UrgencyFromString ¶
UrgencyFromString maps lerd's notification urgency strings to the DBus hint. Unknown or empty values are Normal, matching the Web Push default.