zenity/notify_unix.go

31 lines
768 B
Go
Raw Permalink Normal View History

2022-03-24 10:37:37 -04:00
//go:build !windows && !darwin
2020-01-26 11:04:49 -05:00
package zenity
2022-05-11 12:49:15 -04:00
import "github.com/ncruces/zenity/internal/zenutil"
2020-01-26 11:31:23 -05:00
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-04-08 11:43:14 -04:00
args = appendTitle(args, opts)
2020-01-26 11:31:23 -05:00
switch opts.icon {
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")
2021-03-05 10:14:30 -05:00
case PasswordIcon:
args = append(args, "--window-icon=dialog-password")
case NoIcon:
args = append(args, "--window-icon=dialog")
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
}