Make Klipper Work FOR you

“Klipper is the KDE clipboard utility. It stores clipboard history, and allows you to link clipboard contents to application actions.” That’s the common explanation you get from most people and online manuals when seeking information about Klipper. But what else can Klipper do? Is that ALL it does? Can we empower it to be what cut and past is in Windows? (ducks the possible flames) Perhaps. Grab a pen and paper Klip…let’s see what this thing can do. Please note that this article is written with the assumption that you are using KDE 3.4 or higher.

In most KDE default KDE desktops on the major distros, you find this little icon:

That icon is Klipper, your clipboard tool. A clipboard is just what it sounds like…a place where you can clip text to be used at a later date. I wanted to take a look at where Klipper came from…so I went into the ‘about Klipper’ menu and emailed a couple of developers. A few actually responded quelling the myth that developers are unreachable by the general public. Carsten Pfeiffer, a previous developer, responded about the history of Klipper:

“It was started long time ago by Andrew Stanley-Jones, for storing a history of clipboard entries. I took over maintainership and added those annoying popups, that appeared, for example when you selected a URL in a terminal or somewhere else. The popup allowed you to do something with the URL, like opening it in Konqueror or Mozilla.

More generally speaking, the feature allowed you to configure custom “actions” to execute when something specific, described with a regular expression was put into the clipboard (see klipper’s Preferences dialog).

Later, I attempted to make klipper hide X11’s IMNSHO broken concept of “Selection” and “Clipboard”, but I didn’t really accomplish that.

Later, Lubos Lunak worked hard on fixing Qt’s clipboard implementation and making klipper play well with it and now I’m very happy that Esben is taking care of it.”

I contacted Esben in an attempt to get some inside information about where Klipper might go in the future (integration into KDE-core perhaps? or other such directions). He was able to provide a few possible directions Klipper may go:

“My vision of Klipper is mostly as a clipboard history application… the actions I merely maintain for those that uses them. Thus the features I have implemented so far has centered on the history: Expanding the history (really making the history scalable), support for images (this was sort of a test, I want to support abitrary mime types in history) and search-as-you type support.”

Now that we know where Klipper came from and where it might be going…let’s take a look at where Klipper can go by making it work for you. By clicking your mouse on Klipper or pressing CNTRL-ALT-V, you can access the menu which shows the text currently stored. When this menu pops open, you can search through it simply by typing your query. Klipper hunts the text down that you’re typing. Easy enough to find text…but where we are concerned with for this article is ‘configure klipper’,which is where you can access the menu where customization is king. Let’s see what we can do. Start by opening up the ‘Configure Klipper’ menu.

You’re greeted by a three-tabbed layout that seems easy enough to navigate. Tab 1 is “General” and is where all of your general settings are stored (go figure) such as pop-ups for Klipper and Clipboard size. Tab 2 is “Actions” and is where all of the application actions are stored (we’ll explain these later). Tab 3 is “Shortcuts” and has to deal with Clipboard shortcuts while you are in various applications. We’ll cover shortcuts later as well. For now, let’s take things one step at a time and access Tab 1. If it isn’t selected, select it now by left-clicking your mouse on the tab labeled “General.” You should see the image displayed at the beginning of this paragraph.

The General Tab

The tab marked general contains your most commonly used settings. Klipper allows cut and past of text with Control X and Control V respectively…just like the other operating system does. However, unlike that other operating system, Klipper has two buffers for storing text. One buffer is the “selection” buffer. This buffer allows Klipper to store text when you use your mouse to highlight it. You wouldn’t even need to hit Control C to copy it or Control X to cut it…it would already be present in the “selection” buffer. Now, this isn’t always right for everyone so you can choose to Synchronize the “selection” buffer with the “clipboard” buffer…that is, the other buffer that Klipper saves things to. This buffer can be thought of as the normal clipboard buffer where text is cut and pasted from and to. The settings that control both of these buffers is located in the middle of the “general” tab under “Clipboard/Selection Behavior.” Selecting “Separate clipboard and selection” will cause your clipboard to be completely separate from your selection buffer. Selecting “Synchronize contents…” will synchronize things so that you can highlight text to copy it.

Another often forgotten function of this “selection” buffer, is the abiltiy to use the middle mouse button to paste. Of course, this is only if your middle mouse button works in Linux…and if it doesn’t, please visit the forum and we’ll get you up and running.

Cycling through the settings, we can see as the first setting “Pop-up menu at mouse cursor.” Toggling this on or off will allow the Klipper pop-up menus to happen either in your KDE Panel or at your mouse position. Next up is “save on exit.” This setting is used to access text that you saved in a previous KDE session in Klipper. The next setting is “Remove whitespace.” I love this setting because it removes extra spaces from the text you select/cut/paste. This is handy for cutting and pasting urls and downloads. The “Replay actions” setting will cause the actions for the text that is present in Klipper to display in a pop-up. We go into further detail on this later.

“Prevent and empty clipboard” does exactly what it sounds like it does so we won’t explain that one. Moving further down, “Ignore Selection” means that when you highlight text, Klipper won’t save it in its selection buffer (which we discussed earlier). So really, “Ignore Selection” is a switch to turn off your selection buffer. The two settings after this were discussed in the previous paragraph so we’ll skip them now. The timeout action for pop-ups sets the time that pop-ups will remain visible to you. The last setting is very simply a way to set how many clipboard entries/items are stored in Klipper.

Actions Tab

If you dabble in programming, the actions tab is for you. Actions are based on the Qt 4.0 regexp class which provides a way to dynamically use text. It is important to note that Klipper does not support the wildcard options in the class noted above. So what can this action tab do? Well, you can setup actions to take place on the text in the clipboard. For instance, in the picture at the beginning of this paragraph, you can see the setting “^V.+\.jpg$”. This setting contains one action beneath it…which is “Kview %s”. The “%s” is an alias that stands for the most recent text selection you have on your clipboard. So…if we were to select text that ended in somename.jpg, Klipper would launch Kview to view this picture since the actions denote that it should. You can add other applications in here if you know what name or expression they use to execute. For more advanced use of this function, see the class link above or try the Klipper Handbook Actions Entry.

One good action I came up with was adding Firefox to my URL action in Klipper. This way, when I selected a URL, the pop-up window asked me if I’d like to open it in Firefox. Of course, I chose yes. This is a very simple example…I hope other people have more they might be able to provide to supplement this article with.

The actions menu can really be a powerful area of customization. However, having not used Klipper as much as I should be and only really getting into using it for the last few weeks…I’m not too experienced in tapping into these settings. If anyone has any suggestions as to actions that work for them or suggestions as to what actions and expressions in this menu might provide a better KDE experience, please comment below.

Shortcuts Tab

The shortcuts tab allows you to change the Keyboard shortcuts that are used to access Klipper. Switch them to whatever shortcut you want. Don’t like Control V for paste? Change it! You can even assign an action a shortcut key combination. Klipper leaves it up to you to decide how you want things…it doesn’t decide for you. To change a shortcut, select “Custom” and make your changes. To return to the normal setting, choose “Default.” You can also blank out your setting by choosing “None”.

As you can see, Klipper makes life much easier in Linux that it ever could be without it. The meat and potatoes of Klipper is the action menu and I wish I had more to give everyone to show them how powerful Klipper could be. I did do some poking around on the net to see if I could find a listing of actions or even a few handy ones but I came up pretty much empty. It seems no one has collected Klipper actions. So, here is as good as any place to collect actions right? If you have an action that you find handy, please post it in the comments below. If it checks out and works great, I’ll post it in this article and give you reference for it. Thanks for reading!

7 thoughts on “Make Klipper Work FOR you”

I have lamented in the past (some referred to it as “sniveled”) that a cool program for windoze is not available in Linux. It is called shortkeys and works simply.

Setting up shortkeys is easy. Lets say I get tired of typeing the name of my company MobileMaster of Austin. In Shortkeys, I can assign a keyboard macro of anything I like to represent my compamny name. In other words I can program “mmm” to represent mobilemaster of austin. As I am typing a letter or email, instead of typing my company name, I simply type “mmm” and MobileMaster of Austin appears. Am I seeing this ability in klipper, or something close to it?

I want to do the following, many times I need to email a lot of people, but email is not just one selection, usually is 2 or 3 (recipient, subject, body). I wonder how can I paste all 3 without having to go to klipper history menu. I saw Cltr-Alt-Down but this doesnt work since Cltr-alt already change my keyboard layout. I could play out with something else, but I am not sure how. For example, Ctlr-Alt-V wouldnt show the menu, instead it will change the keyboard layout.

By clicking your mouse on Klipper or pressing CNTRL-ALT-V, you can access the menu which shows the text currently stored

This can be done…kind of. You’d use Klipper actions to script something in this fashion…however, I’m not aware of anyone out there tackling this or addressing it anywhere. I’ll try to look into it and post if I find anything

Easier question, I did some shortcut edit on KDE and finally got to make the Klipper history usable (META-Ctrl-Down/up). I am able to go throught he clipboard history, once I have the seleccion on current, I am still unable (or dont know how to paste it). Ctrl-V still paste the latest content as opposed to the current.