Fix defaults (unix).

This commit is contained in:
Nuno Cruces 2021-03-04 12:35:27 +00:00
parent 7dc0e92528
commit abdae34d4e
4 changed files with 23 additions and 22 deletions

View file

@ -14,8 +14,8 @@ func selectColor(options []Option) (color.Color, error) {
args := []string{"--color-selection"} args := []string{"--color-selection"}
if opts.title != "" { if opts.title != nil {
args = append(args, "--title", opts.title) args = append(args, "--title", *opts.title)
} }
if opts.color != nil { if opts.color != nil {
args = append(args, "--color", zenutil.UnparseColor(opts.color)) args = append(args, "--color", zenutil.UnparseColor(opts.color))

View file

@ -16,8 +16,8 @@ func selectFile(options []Option) (string, error) {
if opts.directory { if opts.directory {
args = append(args, "--directory") args = append(args, "--directory")
} }
if opts.title != "" { if opts.title != nil {
args = append(args, "--title", opts.title) args = append(args, "--title", *opts.title)
} }
if opts.filename != "" { if opts.filename != "" {
args = append(args, "--filename", opts.filename) args = append(args, "--filename", opts.filename)
@ -44,8 +44,8 @@ func selectFileMutiple(options []Option) ([]string, error) {
if opts.directory { if opts.directory {
args = append(args, "--directory") args = append(args, "--directory")
} }
if opts.title != "" { if opts.title != nil {
args = append(args, "--title", opts.title) args = append(args, "--title", *opts.title)
} }
if opts.filename != "" { if opts.filename != "" {
args = append(args, "--filename", opts.filename) args = append(args, "--filename", opts.filename)
@ -72,8 +72,8 @@ func selectFileSave(options []Option) (string, error) {
if opts.directory { if opts.directory {
args = append(args, "--directory") args = append(args, "--directory")
} }
if opts.title != "" { if opts.title != nil {
args = append(args, "--title", opts.title) args = append(args, "--title", *opts.title)
} }
if opts.filename != "" { if opts.filename != "" {
args = append(args, "--filename", opts.filename) args = append(args, "--filename", opts.filename)

View file

@ -26,8 +26,8 @@ func message(kind messageKind, text string, options []Option) (bool, error) {
if text != "" { if text != "" {
args = append(args, "--text", text, "--no-markup") args = append(args, "--text", text, "--no-markup")
} }
if opts.title != "" { if opts.title != nil {
args = append(args, "--title", opts.title) args = append(args, "--title", *opts.title)
} }
if opts.width > 0 { if opts.width > 0 {
args = append(args, "--width", strconv.FormatUint(uint64(opts.width), 10)) args = append(args, "--width", strconv.FormatUint(uint64(opts.width), 10))
@ -35,14 +35,14 @@ func message(kind messageKind, text string, options []Option) (bool, error) {
if opts.height > 0 { if opts.height > 0 {
args = append(args, "--height", strconv.FormatUint(uint64(opts.height), 10)) args = append(args, "--height", strconv.FormatUint(uint64(opts.height), 10))
} }
if opts.okLabel != "" { if opts.okLabel != nil {
args = append(args, "--ok-label", opts.okLabel) args = append(args, "--ok-label", *opts.okLabel)
} }
if opts.cancelLabel != "" { if opts.cancelLabel != nil {
args = append(args, "--cancel-label", opts.cancelLabel) args = append(args, "--cancel-label", *opts.cancelLabel)
} }
if opts.extraButton != "" { if opts.extraButton != nil {
args = append(args, "--extra-button", opts.extraButton) args = append(args, "--extra-button", *opts.extraButton)
} }
if opts.noWrap { if opts.noWrap {
args = append(args, "--no-wrap") args = append(args, "--no-wrap")
@ -65,10 +65,11 @@ func message(kind messageKind, text string, options []Option) (bool, error) {
} }
out, err := zenutil.Run(opts.ctx, args) out, err := zenutil.Run(opts.ctx, args)
if err, ok := err.(*exec.ExitError); ok && err.ExitCode() != 255 { if len(out) > 0 && opts.extraButton != nil &&
if len(out) > 0 && string(out[:len(out)-1]) == opts.extraButton { string(out[:len(out)-1]) == *opts.extraButton {
return false, ErrExtraButton return false, ErrExtraButton
} }
if err, ok := err.(*exec.ExitError); ok && err.ExitCode() == 1 {
return false, nil return false, nil
} }
if err != nil { if err != nil {

View file

@ -14,8 +14,8 @@ func notify(text string, options []Option) error {
if text != "" { if text != "" {
args = append(args, "--text", text, "--no-markup") args = append(args, "--text", text, "--no-markup")
} }
if opts.title != "" { if opts.title != nil {
args = append(args, "--title", opts.title) args = append(args, "--title", *opts.title)
} }
switch opts.icon { switch opts.icon {
case ErrorIcon: case ErrorIcon: