Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I use the Actions feature of KDE's Klipper utility to run certain commands when I copy something into the clipboard that matches a particular regular expression. Unfortunately, I have to turn on Enable Clipboard Actions and select the command from a menu every time I copy something that I want to run the command on. I'd like to have that command run automatically instead.

You'd think this was possible, as there is an automatic checkbox in the action settings dialog box:

Unfortunately, that appears to do nothing. The documentation included with Klipper does not indicate what that checkbox is supposed to do.

Is it possible to configure Klipper to run a command automatically if the contents of the clipboard matches a regular expression? If not, is there another way to accomplish this?

share|improve this question

1 Answer 1

up vote 2 down vote accepted
+100

I have found no way to tell klipper to apply the action automatically. The most what clipper can do automatically is pop up a menu with the actions. It will take another mouse click to actually apply the action.

The Automatic checkbox in the action properties dialog has the following effect: if you copy a text, and the text matches a configured regular expression, then a menu with the corresponding actions pops up. Note that Enable Clipboard Actions must be enabled for this. If either Enable Clipboard Actions or Automatic is disabled, then no menu will appear upon a copy.

For alternatives: I looked around and found no clipboard manager which does what you want (match regex, modify clipboard content automatically). I tested some clipboard managers which offer similar functionality to klipper. They all do not apply the actions automatically, instead, they offer a popup menu for the configured action, just like klipper.

It seems you will have to code your own solution.

A naive implementation might look like this:

  1. Monitor content of clipboard.
  2. If content changes, match against regex.
  3. If regex matches, modify content of clipboard.

It shouldn't be too hard to code that up using, for example, python and PyGTK or PyQt.

Alternatively you can hack up a shell script using the command xclip -o to dump the content of the clipboard, and xclip -i to insert the modified content into the clipboard.

This project seems to have implemented point number 1 and some of number 2 using perl and the xclip command. Maybe you can start form there and modify it to suit your needs.

share|improve this answer
1  
Thanks for the pointer to xclip; that makes writing something to do what I need dead simple. –  Patches May 26 '11 at 8:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.