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-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
|
|
|
}
|