feat: implement security, discovery, history, file transfer, web UI (P0-P3)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
//go:build darwin
|
||||
|
||||
package notify
|
||||
|
||||
import "os/exec"
|
||||
|
||||
// Notifier uses osascript (Notification Center) on macOS.
|
||||
type notifier struct{}
|
||||
|
||||
// New returns a macOS notifier using osascript.
|
||||
func New() Notifier { return notifier{} }
|
||||
|
||||
func (notifier) Notify(title, body string) error {
|
||||
script := "display notification " + quote(body) + " with title " + quote(title)
|
||||
return exec.Command("osascript", "-e", script).Run()
|
||||
}
|
||||
|
||||
func quote(s string) string {
|
||||
out := `"`
|
||||
for _, r := range s {
|
||||
switch r {
|
||||
case '\\', '"':
|
||||
out += "\\" + string(r)
|
||||
default:
|
||||
out += string(r)
|
||||
}
|
||||
}
|
||||
return out + `"`
|
||||
}
|
||||
Reference in New Issue
Block a user