diff --git a/color_unix.go b/color_unix.go index ef155ac..3feeba8 100644 --- a/color_unix.go +++ b/color_unix.go @@ -14,8 +14,8 @@ func selectColor(options []Option) (color.Color, error) { args := []string{"--color-selection"} - if opts.title != "" { - args = append(args, "--title", opts.title) + if opts.title != nil { + args = append(args, "--title", *opts.title) } if opts.color != nil { args = append(args, "--color", zenutil.UnparseColor(opts.color)) diff --git a/file_unix.go b/file_unix.go index 55e375f..a62b418 100644 --- a/file_unix.go +++ b/file_unix.go @@ -16,8 +16,8 @@ func selectFile(options []Option) (string, error) { if opts.directory { args = append(args, "--directory") } - if opts.title != "" { - args = append(args, "--title", opts.title) + if opts.title != nil { + args = append(args, "--title", *opts.title) } if opts.filename != "" { args = append(args, "--filename", opts.filename) @@ -44,8 +44,8 @@ func selectFileMutiple(options []Option) ([]string, error) { if opts.directory { args = append(args, "--directory") } - if opts.title != "" { - args = append(args, "--title", opts.title) + if opts.title != nil { + args = append(args, "--title", *opts.title) } if opts.filename != "" { args = append(args, "--filename", opts.filename) @@ -72,8 +72,8 @@ func selectFileSave(options []Option) (string, error) { if opts.directory { args = append(args, "--directory") } - if opts.title != "" { - args = append(args, "--title", opts.title) + if opts.title != nil { + args = append(args, "--title", *opts.title) } if opts.filename != "" { args = append(args, "--filename", opts.filename) diff --git a/msg_unix.go b/msg_unix.go index eba957e..7912b6c 100644 --- a/msg_unix.go +++ b/msg_unix.go @@ -26,8 +26,8 @@ func message(kind messageKind, text string, options []Option) (bool, error) { if text != "" { args = append(args, "--text", text, "--no-markup") } - if opts.title != "" { - args = append(args, "--title", opts.title) + if opts.title != nil { + args = append(args, "--title", *opts.title) } if opts.width > 0 { 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 { args = append(args, "--height", strconv.FormatUint(uint64(opts.height), 10)) } - if opts.okLabel != "" { - args = append(args, "--ok-label", opts.okLabel) + if opts.okLabel != nil { + args = append(args, "--ok-label", *opts.okLabel) } - if opts.cancelLabel != "" { - args = append(args, "--cancel-label", opts.cancelLabel) + if opts.cancelLabel != nil { + args = append(args, "--cancel-label", *opts.cancelLabel) } - if opts.extraButton != "" { - args = append(args, "--extra-button", opts.extraButton) + if opts.extraButton != nil { + args = append(args, "--extra-button", *opts.extraButton) } if opts.noWrap { 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) - if err, ok := err.(*exec.ExitError); ok && err.ExitCode() != 255 { - if len(out) > 0 && string(out[:len(out)-1]) == opts.extraButton { - return false, ErrExtraButton - } + if len(out) > 0 && opts.extraButton != nil && + string(out[:len(out)-1]) == *opts.extraButton { + return false, ErrExtraButton + } + if err, ok := err.(*exec.ExitError); ok && err.ExitCode() == 1 { return false, nil } if err != nil { diff --git a/notify_unix.go b/notify_unix.go index a8ac60b..e471a51 100644 --- a/notify_unix.go +++ b/notify_unix.go @@ -14,8 +14,8 @@ func notify(text string, options []Option) error { if text != "" { args = append(args, "--text", text, "--no-markup") } - if opts.title != "" { - args = append(args, "--title", opts.title) + if opts.title != nil { + args = append(args, "--title", *opts.title) } switch opts.icon { case ErrorIcon: