xselection
Guido Berhoerster
gber at opensuse.org
Mon Feb 27 21:12:05 CET 2012
* Ulli Horlacher <framstag at rus.uni-stuttgart.de> [2012-02-27 11:58]:
> Is there a hook for xselection access?
>
> I want to start a program which will save the xselection clipboard text
> to a file whenever its contens has changed.
>
> Polling xselection every x seconds via xclip is not very effizient :-}
This doesn't have much to do with Xfce, but anyway. Reasonably
modern X implementations with support for the XFIXES extension
provide event notification on selection ownership changes so you
don't have to resort to polling. Note that an ownership change
event should be triggered each time the selection is changed even
if the new owner is the same as the previous owner.
If you're ok with using GTK rather than raw Xlib it is fairly
convenient to obtain the selection's contents on any change.
Basically, you need to obtain a pointer to the GtkClipboard
object of the desired selection and use it to connect a callback
to its "owner-change" signal. In the callback you can then
retrieve any text contents and append them to a file. See
http://developer.gnome.org/gtk/2.24/gtk-Clipboards.html for the
details.
--
Guido Berhoerster
More information about the Xfce
mailing list