Binding mouse buttons to copy and paste

6,511

Solution 1

Yes, it is possible, and there are many ways to do it.

The easiest way, which isn't exactly what you want, is to use a clipboard manager to bind middle-clicking to pasting. Glippy, which I use, allows me to do this. It has a setting that makes anything you highlight automatically copied to the clipboard and whatever is in the clipboard pasted by midle clicking. I'd don't use this because it's incredibly annoying, but the option is there. Glippy: https://launchpad.net/~bikooo/+archive/glippy

To do exactly what you want you can use xte. Xte is part of the "xautomation" package:

sudo apt-get install xautomation

Assuming you're using Compiz, open the Compiz Config Manager. Go to the "Commands" section, then enter something like this as a command:

xte 'keydown Control_L' 'key c' 'keyup Control_L'

The go to the "Button Bindings" tab and map the command to Ctrl+Button3.

Now holding Ctr and pressing the right mouse button will act as pressing Ctrl+C.

To also get this behavior in a terminal the command would be:

xte 'keydown Control_L' 'keydown Shift_L' 'key c' 'keyup Control_L' 'keyup Shirt_L'

To learn more about how to emulate key presses with xte type

man xte

Into a terminal after you install xautomation.

Solution 2

If you use Unity, give this a try:

http://thecodecentral.com/2012/07/27/use-mouse-buttons-to-perform-copy-paste-in-ubuntu

Share:
6,511

Related videos on Youtube

indi
Author by

indi

Updated on September 17, 2022

Comments

  • indi
    indi over 1 year

    Often I'm copying and pasting pieces of text. I'd like to streamline the process.

    Anyone know if it possible to bind (for example): Ctrl Right Click to Copy and Alt Right Click to Paste

    • Admin
      Admin over 13 years
      Why cant you hightlight with left button and paste it with middle button..
    • Admin
      Admin over 13 years
      @karthick87: this should be an answer ;)
    • Admin
      Admin over 13 years
      @Takkat He is asking for binding mouse buttons..
  • Eric Carvalho
    Eric Carvalho over 11 years
    You should provide step by step instructions here, not simply direct to a link. By the way, prerequisite is compiz, not Unity.