add desktop notifications
This commit is contained in:
parent
2c5c9628c4
commit
f637ca23d4
17
goutil.go
17
goutil.go
|
@ -293,3 +293,20 @@ func Execute(possibleCommands []Command) error {
|
||||||
return cmd.exec(os.Args[2:])
|
return cmd.exec(os.Args[2:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Notify(head string, body string) error {
|
||||||
|
var cmd *exec.Cmd
|
||||||
|
goos := runtime.GOOS
|
||||||
|
switch goos {
|
||||||
|
case "windows":
|
||||||
|
cmd = nil
|
||||||
|
case "darwin":
|
||||||
|
cmd = exec.Command("osascript", "-e", `display notification "`+body+`" with title "`+head+`"`)
|
||||||
|
default:
|
||||||
|
cmd = exec.Command("notify-send", head, body)
|
||||||
|
}
|
||||||
|
if cmd != nil {
|
||||||
|
return cmd.Start()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user