add desktop notifications

This commit is contained in:
gutmet 2019-01-13 10:24:46 +01:00
parent 2c5c9628c4
commit f637ca23d4

View File

@ -293,3 +293,20 @@ func Execute(possibleCommands []Command) error {
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
}