github.com/puellanivis/breton@v0.2.16/lib/files/clipboard/clip_posix.go (about) 1 //go:build dragonflybsd || freebsd || linux || netbsd || openbsd || solaris 2 // +build dragonflybsd freebsd linux netbsd openbsd solaris 3 4 package clipboard 5 6 import ( 7 "os/exec" 8 ) 9 10 var ( 11 pasteCmd []string 12 copyCmd []string 13 selParam []string 14 ) 15 16 var ( 17 xclipPaste = []string{"-out"} 18 xclipCopy = []string{"-in"} 19 ) 20 21 var ( 22 xselPaste = []string{"--output"} 23 xselCopy = []string{"--input"} 24 ) 25 26 var defaultClipboard clipboard 27 28 func init() { 29 if cmd, err := exec.LookPath("xclip"); err == nil { 30 pasteCmd = append([]string{cmd}, xclipPaste...) 31 copyCmd = append([]string{cmd}, xclipCopy...) 32 selParam = []string{"-selection"} 33 34 newExecClip("", "clipboard") 35 defaultClipboard = clipboards[""] 36 37 newExecClip("clipboard") 38 newExecClip("primary") 39 newExecClip("secondary") 40 return 41 } 42 43 cmd, err := exec.LookPath("xsel") 44 if err != nil { 45 return 46 } 47 48 pasteCmd = append([]string{cmd}, xselPaste...) 49 copyCmd = append([]string{cmd}, xselCopy...) 50 selParam = []string{} 51 52 newExecClip("", "--clipboard") 53 defaultClipboard = clipboards[""] 54 55 newExecClip("clipboard", "--clipboard") 56 newExecClip("primary", "--primary") 57 newExecClip("secondary", "--secondary") 58 }