I mean I would like to make an event handler to run when data is copied to the clipboard (and an appropritae event handler is fired), and making some text processing on the clipboard data.
This doesn't make sense to me. There is xsel, but if you are writing an event handler, you must be using a language with Xlib bindings already - so why not access the selection data directly?
Currently I am using the Clipit clipboard manager, but I am looking for another one which fires an event when data is copied to the clipboard, and it runs an arbitrary script file which handles the event: eg process the data on the clipboard, replace parts of the text as necessary, runs through filters, regular expressions etc. This would be very helpful in some situations. You don't have to copy the text and paste it in a text editor, then replacing some text, copy again, and paste it on another document.
I doubt something exactly like that exists yet, but if you know any C it would be pretty easy to make.
As an alternative, you could just bind a script to a key of choice that does the following:
xsel | sed 's/.../' | xsel -b -i
replace sed with awk, or whatever processing you'd want to do. When you call this script (say you rebind Ctrl-C to call this script) whatever is currently selected will be processed, by sed in this case, and written to the clipboard.
Thx, but how can I rebind Ctrl+C ?
Unfortunately I don't know C programming, I know only Ruby and bash script.
Bind keys with Xbindkeys, or through your window manager.