linux剪贴板在C中读/写

linux clipboard read/write in C

我做了很多谷歌搜索,但我仍然不确定如何继续。

在Linux下读/写剪贴板最常用的方法是什么? 我想要支持Gnome& KDE桌面。

更新:我认为没有一个简单的解决方案,必须将多个来源(gnome,kde)"聚合"在一起才能制定解决方案?


也许你可以看看xclip,看看他们是如何做到的。

It provides an interface to X
selections ("the clipboard") from the
command line. It can read data from
standard in or a file and place it in
an X selection for pasting into other
X applications. xclip can also print
an X selection to standard out, which
can then be redirected to a file or
another program.


我可能会在脚下射击自己,但是这可以给你一个关于如何为kde做剪贴板的提示,不确定Gnome自己但是试试看,脚本在python中并演示了如何获取/设置剪贴板上的东西 ,通过使用dcop和klipper,它在这个网站上。

希望这可以帮助,
最好的祝福,
汤姆。