//go:build darwin package main import ( "fmt" "strings" ) func platformStartupChannels(runner commandRunner) []promptChannel { return []promptChannel{ { name: "macos-notification", available: func() error { _, err := runner.LookPath("osascript") return err }, run: func(req promptRequest) error { script := fmt.Sprintf(`display notification "%s" with title "%s" subtitle "%s"`, escapeAppleScript(req.message), escapeAppleScript(req.title), escapeAppleScript(req.subtitle)) return runner.Run(promptCommandTimeout, nil, "osascript", "-e", script) }, }, { name: "macos-alert", available: func() error { _, err := runner.LookPath("osascript") return err }, run: func(req promptRequest) error { script := fmt.Sprintf(`display alert "%s" message "%s" as critical buttons {"OK"} default button "OK"`, escapeAppleScript(req.title), escapeAppleScript(req.message)) return runner.Run(promptCommandTimeout, nil, "osascript", "-e", script) }, }, } } func escapeAppleScript(s string) string { s = strings.ReplaceAll(s, "\\", "\\\\") s = strings.ReplaceAll(s, "\"", "\\\"") return s }