zenity/notify_unix.go

37 lines
722 B
Go
Raw Permalink Normal View History

2020-01-26 11:04:49 -05:00
// +build !windows,!darwin
package zenity
2020-01-26 11:31:23 -05:00
import (
"github.com/ncruces/zenity/internal/zenutil"
)
2020-01-26 11:04:49 -05:00
func notify(text string, options []Option) error {
2020-01-26 11:31:23 -05:00
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
2020-01-26 11:04:49 -05:00
}