2020-01-26 11:04:49 -05:00
|
|
|
package zenity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2024-07-10 00:06:01 -04:00
|
|
|
"git.bigun.dev/evan/zenity/internal/zenutil"
|
2020-01-26 11:04:49 -05:00
|
|
|
)
|
|
|
|
|
2021-03-04 07:42:30 -05:00
|
|
|
func notify(text string, opts options) error {
|
2021-02-19 12:46:47 -05:00
|
|
|
var data zenutil.Notify
|
|
|
|
data.Options.Title = opts.title
|
2023-01-10 09:26:14 -05:00
|
|
|
if sub, body, cut := strings.Cut(text, "\n"); cut {
|
|
|
|
data.Options.Subtitle = sub
|
|
|
|
data.Text = body
|
|
|
|
} else {
|
|
|
|
data.Text = text
|
2020-01-26 11:04:49 -05:00
|
|
|
}
|
2023-01-10 09:26:14 -05:00
|
|
|
|
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
|
|
|
|
}
|