Skip to content

Commit

Permalink
Merge pull request #16 from meliksah/bugfix/issue-15
Browse files Browse the repository at this point in the history
  • Loading branch information
quackduck authored Feb 24, 2023
2 parents f3dbb3e + 973a413 commit 022bec3
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions uniclip.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func MonitorSentClips(r *bufio.Reader) {
continue
}
}

foreignClipboard = string(foreignClipboardBytes)
// hacky way to prevent empty clipboard TODO: find out why empty cb happens
if foreignClipboard == "" {
Expand All @@ -198,14 +199,16 @@ func MonitorSentClips(r *bufio.Reader) {
func sendClipboard(w *bufio.Writer, clipboard string) error {
var clipboardBytes []byte
var err error
clipboardBytes = []byte(clipboard)
//clipboardBytes = compress(clipboard)
//fmt.Printf("cmpr: %x\ndcmp: %x\nstr: %s\n\ncmpr better by %d\n", clipboardBytes, []byte(clipboard), clipboard, len(clipboardBytes)-len(clipboard))
if secure {
clipboardBytes, err = encrypt(password, []byte(clipboard))
clipboardBytes, err = encrypt(password, clipboardBytes)
if err != nil {
return err
}
}

err = gob.NewEncoder(w).Encode(clipboardBytes)
if err != nil {
return err
Expand Down Expand Up @@ -345,7 +348,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")
Expand All @@ -369,15 +372,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)
Expand Down

0 comments on commit 022bec3

Please sign in to comment.