zenity/notify_unix.go
2020-01-26 16:31:23 +00:00

37 lines
722 B
Go

// +build !windows,!darwin
package zenity
import (
"github.com/ncruces/zenity/internal/zenutil"
)
func notify(text string, options []Option) error {
opts := applyOptions(options)
args := []string{"--notification"}
if text != "" {
args = append(args, "--text", text, "--no-markup")
}
if opts.title != "" {
args = append(args, "--title", opts.title)
}
switch opts.icon {
case ErrorIcon:
args = append(args, "--window-icon=error")
case WarningIcon:
args = append(args, "--window-icon=warning")
case InfoIcon:
args = append(args, "--window-icon=info")
case QuestionIcon:
args = append(args, "--window-icon=question")
}
_, err := zenutil.Run(args)
if err != nil {
return err
}
return nil
}