mirror of
https://github.com/m1k1o/neko.git
synced 2025-06-22 04:28:16 +02:00
extract clipboard from xorg.
This commit is contained in:
parent
2be071d215
commit
e3e3cf9d22
7 changed files with 70 additions and 47 deletions
35
server/internal/remote/clipboard/clipboard.go
Normal file
35
server/internal/remote/clipboard/clipboard.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package clipboard
|
||||
|
||||
/*
|
||||
#cgo linux LDFLAGS: /usr/local/lib/libclipboard.a -lxcb
|
||||
|
||||
#include "clipboard.h"
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var mu = sync.Mutex{}
|
||||
|
||||
func Read() string {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
clipboardUnsafe := C.ClipboardGet()
|
||||
defer C.free(unsafe.Pointer(clipboardUnsafe))
|
||||
|
||||
return C.GoString(clipboardUnsafe)
|
||||
}
|
||||
|
||||
func Write(data string) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
clipboardUnsafe := C.CString(data)
|
||||
defer C.free(unsafe.Pointer(clipboardUnsafe))
|
||||
|
||||
C.ClipboardSet(clipboardUnsafe)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue