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.

For some time I've been interested in binding the Windows Key (Super_L) on my keyboard to Copy and Paste for no other reason but convenience and consistency between my desktop and my MacBook.

I thought that I was close after reading about xmodmap and executing the following:

$ # re-map Super_L to Mode_switch, the 3rd col in keymap table `xmodmap -pke`
$ xmodmap -e "keycode  133 = Mode_switch"

$ # map Mode_switch+c to copy
$ xmodmap -e "keycode  54 = c C XF86_Copy C"

$ # map Mode_switch+v to paste
$ xmodmap -e "keycode  55 = v V XF86_Paste V"

Unfortunately, XF86Copy and XF86Paste don't seem to work, at all. They are listed in /usr/include/X11/XF86keysym.h and xev shows that the key sequence is being interpreted by X as XF86Paste and XF86Copy, do these symbols actually work? Do they have to have application level support?

share|improve this question
add comment

3 Answers 3

up vote 5 down vote accepted
+100

Binding Super to Ctrl

What about binding your left Windows/Logo/Super key to act as another Ctrl key?

You can achieve that with the following xmodmap commands:

remove mod4 = Super_L
keysym Super_L = Control_L
add Control = Control_L

Assuming you saved the above lines as super_as_ctrl.xmodmap you can test out the effect by executing

xmodmap super_as_ctrl.xmodmap

To make the change permanent (surviving re-login/reboot) rename the file to .Xmodmap in your home folder.

(The above was tested on Ubuntu 11.10 live system, but it should be the same for other Linux distributions)


Adjusting Copy/Paste shortcuts for your terminal program

Having bound Super to Ctrl you can now use Super-C to copy almost everywhere. The only common exception is your terminal program. However you can redefine the shortcuts there.

I found out that even gnome-terminal has this option by now (I did not have until I got used to Ctrl-Shift-C anyway). In case you use that one, go to Edit / Keyboard Shortcuts... in the menu and assign Ctrl-C to copy and Ctrl-V to paste. Should be similar for konsole etc.

And don't worry, you won't loose the ability to terminate a program using a shortcut. After rebinding the copy shortcut for the terminal, you can just use Ctrl-Shift-C like you used Ctrl-C before. The terminal does not distinguish here if Shift is pressed or not. And the shortcut is not caught anymore for the copy. Alternatively rebind the terminate to another shortcut, as MountainX suggests in his answer.


XF86Copy etc. do not work

Concerning the key symbols for copy and paste: Apparently they have no effect. I tested it quickly by assigning the copy action to Shift-ScrollLock (it was unused and I wanted to test with a non modifier key):

xmodmap -e 'keycode 78 = Scroll_Lock XF86Copy Scroll_Lock'

Pressing it had no effect, neither with XF86AudioMute. However it did work when assigning the letter 'a'. So I guess there is a specific problem with these XF86 special key symbols.

share|improve this answer
    
Unfortunately, even if I bind Super to Ctrl, I will still have to use Ctrl/Super+Shift+C to copy and paste inside the terminal, which is a primary incentive. Thanks confirming that the XF86 keys do not work. –  solo Apr 11 '12 at 19:46
    
What terminal program do you use? I added a solution that does work with gnome-terminal at least. And it should be similar for others. –  zpea Apr 12 '12 at 20:53
add comment

Here's what I do. It is not the ultimate solution, but I tried to achieve the ultimate solution and couldn't get there after much effort. So I settled for something that is simple and that works for more than 90% of what I need. I can implement it on any computer I go to (or any new Linux install) in a matter of minutes. It's dead simple.

In the X terminal application, set the shortcut preferences. I have done this in both Gnome and KDE. In Konsole, for example, go to Menu > Settings > Configure Shortcuts. There is a similar menu in Gnome X terminal. Just select the shortcut (e.g., "copy") and enter the desired key sequence.

In case the terminal copy & paste shortcuts conflict with terminal commands, there's an easy fix for that too. For example, what if someone wants to use CTRL-C for copy (so the X terminal conforms to the CUA standard)?

In that case, you can change the stty key bindings easily (in .bashrc). Continuing the CTRL-C for copy example, say you want the interrupt key to now be CTRL-b (for "break"). This accomplishes that:

echo "stty intr \^b" >> ~/.bashrc 

Then source .bashrc.

The whole solution is as simple as using the X terminals settings to change shortcuts and then, optionally, resolving conflicts with stty with a one-line echo command. Dead simple and covers almost everything I need.

share|improve this answer
add comment

Probably Windows key is modifier key. run this and try again:

xmodmap -e 'remove Mod4 = Super_L'
share|improve this answer
    
Thanks, but doesn't do the trick. I know the mapping is works because xev reports XF86 events. –  solo Apr 11 '12 at 20:08
    
My first post (executing xmodmap -e 'remove Mod1 = Meta_L' and trying your commands after) worked fine for me. –  ussr Apr 12 '12 at 13:17
    
@solo and about working or not, consider not every desktop environment or applications supports them. To find out it really works or not, use them on Firefox for example. It supports (listens to) X key bindings. –  ussr Apr 12 '12 at 13:24
add comment

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.