Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am using Kubuntu Linux 12.04 on a Macbook Pro, and I am seeking the ability to use the Command/Meta key for common shortcuts such as copy, paste, and select all.

Attempted solutions:

  • Remap Copy, Paste, Select All, and others in KDE's System Settings > Shortcuts and Gestures > Standard Keyboard Shortcuts
    • Problem: These shortcuts appear to be ignored by most applications. All web browsers that I tested continued expecting the Ctrl key where I indicated desire of using the Meta key. Due to being unable to find a working web browser, I did not attempt any other applications.
    • Tested in: Firefox, Chromium, Rekonq, Arora, Konqueror.
  • Swap Meta with Ctrl using xmodmap.
    • Problem: Terminal emulators would then require the use of the Meta key in place of the Ctrl key for commands such as the keyboard interrupt, most Emacs bindings, and countless other bindings in various CLI applications.

Considered Solutions:

  • Individually change common shortcuts within GUI applications. Unfortunately, being able to change the bindings for Copy, Paste, and Select All appears to be rare.
  • Change Ctrl modifier for only Konsole (or another terminal emulator.) This would ideally cause Meta-x to produce the keystroke Ctrl-x and vice-versa. I cannot find any way to accomplish this, however.
  • Use stty to change the bindings for terminal key commands to use meta and additionally write custom config files for all other CLI applications. This would require an unreasonable amount of effort to accomplish.

I am extremely surprised at how much effort this simple modification is appearing to require, and I will appreciate any help that can be provided to find a reasonable working solution.

share|improve this question
    
Not any help with your problem but regarding the emacs bindings: Swapped ctrl and meta are actually what emacs binding were designed for because it was developed for Space-cadet keyboards not ibm keyboards. So swapping removes the problem of emacs pinky... –  Trudbert Oct 23 '12 at 14:55
    
Have a look at xbindkeys and at this question on askubuntu about application specific keybinding –  Gerhard Burger Jan 18 '13 at 21:43

1 Answer 1

The Linux kernel generates a code each time a key is pressed on a keyboard. That code is compared to a table of keycodes defining a figure that is then displayed.

This process is complicated by Xorg, which starts its own table of keycodes. Each keycode can belong to a keysym. A keysym is like a function, started by typing a key. Xmodmap allows you to edit these keycode-keysym relations.

To get the current keymap table using Xmodmap use:

xmodmap -pxe

This will print out the full table in the following format:

keycode <keycode#> = <boundkey> <boundkey>

Before moving anything around be sure to backup the original keycode layout using xmodmap -pxe >> $HOME/Xmodmap.orig This will place the file Xmodmap.orig in your users home directory.

Tip: There are also some predefined keycodes (e.g. XF86AudioMute, XF86Mail). Those keycodes can be found in: /usr/include/X11/XF86keysym.h

You can also also edit the keys: Shift, Ctrl, Alt and Super (there always exists a left and a right one (Alt_R=AltGr)).

Here's a quick example of how your configuration would look if you wanted to swap CTRL and Super (Windows Key):

keycode 255  =
!add Shift   = Shift_L Shift_R
!add Lock    = Caps_Lock
add Control  = Super_L Super_R
!add Mod1    = Alt_L Alt_R
!add Mod2    = Mode_switch
!add Mod3    =
add Mod4     = Control_L Control_R
!add Mod5    =

(the ! is used to comment / ignore the line. in this example only Super and Control keys get adjusted)

This configuration would be saved in $HOME/.Xmodmap and loaded with

xmodmap ~/.Xmodmap

You could also start this with xwindows by adding it to your ~/.xinitrc

And if things get hairy you can always revert back to Xmodmap.org.

Any bindings for applications that rely on these keys would also be moved. So make sure that everything remains bound so you don't lose any functionality. It's a tug-of-war match.

share|improve this answer

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.