2020-01-26 11:04:49 -05:00
|
|
|
package zenity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/ncruces/zenity/internal/zenutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
func notify(text string, options []Option) error {
|
|
|
|
opts := applyOptions(options)
|
2021-02-19 12:46:47 -05:00
|
|
|
|
|
|
|
var data zenutil.Notify
|
|
|
|
data.Text = text
|
|
|
|
data.Options.Title = opts.title
|
|
|
|
|
2020-01-26 11:04:49 -05:00
|
|
|
if i := strings.IndexByte(text, '\n'); i >= 0 && i < len(text) {
|
2021-02-19 12:46:47 -05:00
|
|
|
data.Options.Subtitle = text[:i]
|
2020-01-26 11:04:49 -05:00
|
|
|
data.Text = text[i+1:]
|
|
|
|
}
|
2020-01-28 07:46:43 -05:00
|
|
|
_, err := zenutil.Run(opts.ctx, "notify", data)
|
2020-01-26 11:04:49 -05:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|