Kotlin Native Clipboard Linux

Can I do something like this on native?

fun main() {
	val clipboard = Toolkit.getDefaultToolkit().systemClipboard
	val clipboardContent = clipboard.getData(DataFlavor.stringFlavor)

I.e., is there a way to access the clipboard on Linux systems? I found this but this is for MacOS specifically.

Clipboard on Linux is complicated. You have to handle X11 and the myriad of Wayland compositors (gnome, wlroots…). Best way would be to find a toolkit that does that for you. There are some projects bringing gtk to kotlin native that may also be of some help.

1 Like