At a join, at the watcher's start and at a session's start while PORTAL, once per ask, the watcher opens the check address with systemd-run --user and xdg-open in the person's session and then shows the notification its outcome calls for, critical when the open failed; it says when the network is open, and handles what it hears during an open after it. Builds: design 08 sign-in-page §15, §18, §19, §22
22 lines
664 B
Go
22 lines
664 B
Go
package main
|
|
|
|
// Telling the person (design 08 sign-in-page §19): org.freedesktop.Notifications.Notify on the session's bus, the
|
|
// desktop notification service, app_name mesh.
|
|
|
|
import "github.com/godbus/dbus/v5"
|
|
|
|
func notifyOn(bus string, n note) error {
|
|
conn, err := dbus.Connect(bus)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer conn.Close()
|
|
hints := map[string]dbus.Variant{}
|
|
if n.Critical {
|
|
hints["urgency"] = dbus.MakeVariant(byte(2))
|
|
}
|
|
return conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications").
|
|
Call("org.freedesktop.Notifications.Notify", 0, "mesh", uint32(0), "", n.Summary, n.Body, []string{}, hints,
|
|
int32(-1)).Err
|
|
}
|