feat: implement security, discovery, history, file transfer, web UI (P0-P3)
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
// Package notify provides best-effort desktop notifications.
|
||||
//
|
||||
// Each platform file defines its own implementation using //go:build tags:
|
||||
// Linux uses notify-send, macOS uses osascript, Windows is a no-op (Windows
|
||||
// toast notifications require a registered app or a third-party module).
|
||||
package notify
|
||||
|
||||
// Notifier sends a desktop notification.
|
||||
type Notifier interface {
|
||||
Notify(title, body string) error
|
||||
}
|
||||
@@ -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 + `"`
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//go:build linux
|
||||
|
||||
package notify
|
||||
|
||||
import "os/exec"
|
||||
|
||||
// Notifier uses notify-send (libnotify) on Linux.
|
||||
type notifier struct{}
|
||||
|
||||
// New returns a Linux notifier using notify-send.
|
||||
func New() Notifier { return notifier{} }
|
||||
|
||||
func (notifier) Notify(title, body string) error {
|
||||
return exec.Command("notify-send", title, body).Run()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//go:build !linux && !darwin && !windows
|
||||
|
||||
package notify
|
||||
|
||||
// Notifier is a no-op on unsupported platforms.
|
||||
type notifier struct{}
|
||||
|
||||
// New returns a no-op notifier.
|
||||
func New() Notifier { return notifier{} }
|
||||
|
||||
func (notifier) Notify(string, string) error { return nil }
|
||||
@@ -0,0 +1,13 @@
|
||||
//go:build windows
|
||||
|
||||
package notify
|
||||
|
||||
// Notifier is a no-op on Windows. Native toast notifications require a
|
||||
// registered, packaged app (or a third-party module such as BurntToast), which
|
||||
// is out of scope for a single self-contained binary.
|
||||
type notifier struct{}
|
||||
|
||||
// New returns a no-op Windows notifier.
|
||||
func New() Notifier { return notifier{} }
|
||||
|
||||
func (notifier) Notify(string, string) error { return nil }
|
||||
Reference in New Issue
Block a user