30 lines
886 B
Go
30 lines
886 B
Go
//go:build linux || darwin
|
|
|
|
package notify
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
)
|
|
|
|
// send prefers notify-send (Linux) and falls back to osascript (macOS).
|
|
// Notifications persist until clicked, with a 30-second cap.
|
|
// If neither is installed the notification is dropped silently.
|
|
func send(title, body string) error {
|
|
if _, err := exec.LookPath("notify-send"); err == nil {
|
|
return exec.Command("notify-send",
|
|
"-a", "gitflow",
|
|
"-t", "30000", // 30 s timeout
|
|
"-u", "critical", // persist until clicked on most DEs
|
|
"--", title, body,
|
|
).Run()
|
|
}
|
|
if _, err := exec.LookPath("osascript"); err == nil {
|
|
// display notification has no built-in timeout; the system
|
|
// Notification Center settings control dismissal behaviour.
|
|
script := fmt.Sprintf("display notification %q with title %q", body, title)
|
|
return exec.Command("osascript", "-e", script).Run()
|
|
}
|
|
return nil
|
|
}
|