lockbox

password manager
Log | Files | Refs | README | LICENSE

commit 04fd45e82666a94b0cea39d4fb75a5192365f21f
parent 45a8253e04bb5b3db3df8b80b9687af7f24991bb
Author: Sean Enck <sean@ttypty.com>
Date:   Thu, 14 Jul 2022 18:11:31 -0400

try harder to find mode

Diffstat:
Minternal/clip.go | 23++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/internal/clip.go b/internal/clip.go @@ -21,22 +21,27 @@ const ( func GetClipboardCommand() ([]string, []string, error) { env := strings.TrimSpace(os.Getenv("LOCKBOX_CLIPMODE")) if env == "" { - b, err := exec.Command("uname").Output() + b, err := exec.Command("uname", "-a").Output() if err != nil { return nil, nil, err } - uname := strings.TrimSpace(string(b)) - switch uname { + raw := strings.TrimSpace(string(b)) + parts := strings.Split(raw, "") + switch parts[0] { case "Darwin": env = pbClipMode case "Linux": - if strings.TrimSpace(os.Getenv("WAYLAND_DISPLAY")) == "" { - if strings.TrimSpace(os.Getenv("DISPLAY")) == "" { - return nil, nil, NewLockboxError("unable to detect linux clipboard mode") - } - env = xClipMode + if strings.Contains(raw, "microsoft-standard-WSL2") { + env = wslMode } else { - env = waylandClipMode + if strings.TrimSpace(os.Getenv("WAYLAND_DISPLAY")) == "" { + if strings.TrimSpace(os.Getenv("DISPLAY")) == "" { + return nil, nil, NewLockboxError("unable to detect linux clipboard mode") + } + env = xClipMode + } else { + env = waylandClipMode + } } default: return nil, nil, NewLockboxError("unable to detect clipboard mode")