8

I done lots of googling but I am still unsure on how to proceed.

What's the most common way of reading/write to the clipboard under Linux? I want both support for Gnome & KDE desktops.

Updated: do I take there isn't an easy solution and one must "aggregate" together multiple sources (gnome, kde) in order to craft a solution?

jldupont
  • 93,734
  • 56
  • 203
  • 318

2 Answers2

6

Maybe you can look at xclip and see how they have done it.

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.

elig
  • 2,635
  • 3
  • 14
  • 24
Johan
  • 20,067
  • 28
  • 92
  • 110
  • 1
    Your link currently redirects to another site differentiating between windows and unix. No trace of xclip there... – Spikatrix Mar 12 '17 at 06:07
2

I might be shooting myself in the foot, but this could give you a hint on how to do the clipboard for kde, not sure about Gnome myself but try it, the script is in python and demonstrates how to get/set stuff on the clipboard, via using dcop and klipper, it is on this site here.

Hope this helps, Best regards, Tom.

t0mm13b
  • 34,087
  • 8
  • 78
  • 110
  • 2
    Also it might be worth checking out DBUS under Linux, I am more of a Linux CLI junkie so rarely fiddle with a GUI... :) – t0mm13b Nov 26 '09 at 01:06
  • 1
    Sorry for adding more useless blurb here but here's one using ruby and gnome's gtk clipboard...http://swimminginbits.blogspot.com/2009/05/get-and-set-gnome-clipboard-data-from.html Other than that, hopefully for you, at some stage, the api's will be unified to ease your pain here... – t0mm13b Nov 26 '09 at 01:08