diff --git a/msg_unix.go b/msg_unix.go index 25df148..f55023b 100644 --- a/msg_unix.go +++ b/msg_unix.go @@ -48,13 +48,13 @@ func message(kind messageKind, text string, options []Option) (bool, error) { } switch opts.icon { case ErrorIcon: - args = append(args, "--icon-name=dialog-error") + args = append(args, "--window-icon=error", "--icon-name=dialog-error") case WarningIcon: - args = append(args, "--icon-name=dialog-warning") + args = append(args, "--window-icon=warning", "--icon-name=dialog-warning") case InfoIcon: - args = append(args, "--icon-name=dialog-information") + args = append(args, "--window-icon=info", "--icon-name=dialog-information") case QuestionIcon: - args = append(args, "--icon-name=dialog-question") + args = append(args, "--window-icon=question", "--icon-name=dialog-question") } out, err := zenutil.Run(args) diff --git a/notify_test.go b/notify_test.go index 64a3478..1c88f36 100644 --- a/notify_test.go +++ b/notify_test.go @@ -3,8 +3,8 @@ package zenity_test import "github.com/ncruces/zenity" func ExampleNotify() { - zenity.Notify("An error has occurred.", - zenity.Title("Error"), - zenity.Icon(zenity.ErrorIcon)) + zenity.Notify("There are system updates necessary!", + zenity.Title("Warning"), + zenity.Icon(zenity.InfoIcon)) // Output: } diff --git a/notify_unix.go b/notify_unix.go index cf73b97..bf2d3ca 100644 --- a/notify_unix.go +++ b/notify_unix.go @@ -2,6 +2,35 @@ package zenity +import ( + "github.com/ncruces/zenity/internal/zenutil" +) + func notify(text string, options []Option) error { - panic("not implemented") + 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 }