diff --git a/uniclip.go b/uniclip.go index 6a3f02a..d99391e 100644 --- a/uniclip.go +++ b/uniclip.go @@ -172,6 +172,8 @@ func MonitorSentClips(r *bufio.Reader) { handleError(err) continue } + } else { + foreignClipboardBytes = []byte(foreignClipboard) } foreignClipboard = string(foreignClipboardBytes) // hacky way to prevent empty clipboard TODO: find out why empty cb happens @@ -205,6 +207,8 @@ func sendClipboard(w *bufio.Writer, clipboard string) error { if err != nil { return err } + } else { + clipboardBytes = []byte(clipboard) } err = gob.NewEncoder(w).Encode(clipboardBytes) if err != nil { @@ -345,7 +349,7 @@ func setLocalClip(s string) { case "darwin": copyCmd = exec.Command("pbcopy") case "windows": - copyCmd = exec.Command("powershell.exe", "-command", "Set-Clipboard") //-Value "+"\""+s+"\"") + copyCmd = exec.Command("clip") default: if _, err := exec.LookPath("xclip"); err == nil { copyCmd = exec.Command("xclip", "-in", "-selection", "clipboard") @@ -369,15 +373,13 @@ func setLocalClip(s string) { handleError(err) return } - if runtime.GOOS != "windows" { - if _, err = in.Write([]byte(s)); err != nil { - handleError(err) - return - } - if err = in.Close(); err != nil { - handleError(err) - return - } + if _, err = in.Write([]byte(s)); err != nil { + handleError(err) + return + } + if err = in.Close(); err != nil { + handleError(err) + return } if err = copyCmd.Wait(); err != nil { handleError(err)