zenity/notify_unix.go

33 lines
735 B
Go
Raw 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"
)
2021-03-04 07:42:30 -05:00
func notify(text string, opts options) error {
2021-03-05 08:56:16 -05:00
args := []string{"--notification", "--text", text}
2021-03-04 07:35:27 -05:00
if opts.title != nil {
args = append(args, "--title", *opts.title)
2020-01-26 11:31:23 -05:00
}
switch opts.icon {
2021-03-04 08:06:49 -05:00
case NoIcon:
args = append(args, "--window-icon=dialog")
2020-01-26 11:31:23 -05:00
case ErrorIcon:
2021-03-04 08:06:49 -05:00
args = append(args, "--window-icon=dialog-error")
2020-01-26 11:31:23 -05:00
case WarningIcon:
2021-03-04 08:06:49 -05:00
args = append(args, "--window-icon=dialog-warning")
2020-01-26 11:31:23 -05:00
case InfoIcon:
2021-03-04 08:06:49 -05:00
args = append(args, "--window-icon=dialog-information")
2020-01-26 11:31:23 -05:00
case QuestionIcon:
2021-03-04 08:06:49 -05:00
args = append(args, "--window-icon=dialog-question")
2020-01-26 11:31:23 -05:00
}
2020-01-28 07:46:43 -05:00
_, err := zenutil.Run(opts.ctx, args)
2020-01-26 11:31:23 -05:00
if err != nil {
return err
}
return nil
2020-01-26 11:04:49 -05:00
}