Klipper: how to paste current clipboard contents as plain text with a single shortcut action

clipboardkdekeyboard shortcutsklipper

I want to be able to copy rich text with CtrlC, then paste it as plain text with a short cut key (such as CtrlShiftV or whatever).

I'm running KDE and I use Klipper. It seems like there should be a way to make Klipper do this.

Right now I have a 3-step process. I invoke Klipper at the mouse position with a shortcut. Then I select the item from Klipper's contents (even if it is the same item that would already be pasted). Then I paste with CtrlV. I want to reduce this to a single step.

Best Answer

I don't think there's a single-step way to do it with Klipper alone. If you look at its shortcut settings, there are only a limited amount of commands available to bind to keys. Conceivably you could configure something in "Actions", but you'd still need one keystroke to "Manually Invoke Action on Current Clipboard", and another to actually paste. I think your only single-step solution is creating a independent command yourself.

For example, you could install xvkbd, then bind the following to a shortcut key:

xclip -o -selection clipboard | xclip -selection clipboard | xvkbd -xsendevent -text "\\Cv" 2>/dev/null

This reads from the clipboard (in plain text), pipes it back into the clipboard, then invokes Ctrl+v to paste it.

A couple of caveats:

  • This replaces the contents of the clipboard with the "plain" version.
  • This relies on Ctrl+v being the keyboard shortcut to paste, which may not be true (e.g. in some terminal emulators).
Related Question