Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Interestingly, it turns out this is almost impossible to do. Remapping Alt key to behave as another Ctrl key is not a solution because you lose the Alt key functionalities (some of which are essential, like Alt+Tab).

So how can I get a behavior similar to MacOS where cmd key is used for keyboard shortcuts (but also for switching between windows with cmd+Tab)?

I know I can assign Ctrl+Tab to switch between windows after I remap Alt key as a Ctrl key. But then I lose the real Ctrl+Tab functionality in some applications, which are also critical like switching tabs in Chrome. Basically my Ctrl and Alt keys would become the same key and it will be impossible to have two different set of shortcuts for these two modifier keys.

A good solution for me would probably be a way to catch Alt+C, Alt+V, Alt+X, etc. at the window management level and send instead a Ctrl+C or Ctrl+V or Ctrl+X etc. to the focused window. On Windows this was possible via AutoHotKey. On Linux, I heard about an application called AutoKey but unlike AutoHotKey you have to use a GUI to set the shortcuts. Since I will be writing almost all combinations of Alt manually, I don't want a GUI application do to this. I should be able to configure it by writing a text file.

Is it possible to achieve this either with Gnome or Xmonad?

share|improve this question
1  
Can you modify this a bit so it reads more like a question? As it stands, it has the feel of a rant. –  RolandiXor Feb 9 '12 at 17:11
    
You're right. I modified it now. –  Eren Tantekin Feb 9 '12 at 18:18
    
there we go ;)! –  RolandiXor Feb 9 '12 at 18:30
    
has anybody managed to remap copy/paste to alt instead of ctrl on ubuntu (12)? –  yetanothercoder Jan 23 '13 at 9:37

2 Answers 2

You can use XKeyCaps.

This is my .Xmodmap file, I've got an Apple keyboard.

! Swap Alt and Cmd keys.
keycode 37 =    Control_L
keycode 133 =   Alt_L Meta_L
keycode 64 =    Super_L
keycode 108 =   Super_R
keycode 134 =   ISO_Level3_Shift Multi_key
keycode 105 =   Control_R       Multi_key
clear Shift
clear Lock
clear Control
clear Mod1
clear Mod2
clear Mod3
clear Mod4
clear Mod5
add    Shift   = Shift_L Shift_R
add    Lock    = Caps_Lock
add    Control = Control_L Control_R
add    Mod1    = Alt_L 0x007D
add    Mod2    = Num_Lock
add    Mod4    = Super_L Super_R
add    Mod5    = Mode_switch ISO_Level3_Shift ISO_Level3_Shift ISO_Level3_Shift

! Configure '=' key on numpad as '='.
keycode 0x7D =  equal
share|improve this answer

You should be able to use xdotool and additionalKeys from the XMonad.Util.EZConfig module for this. Just install xdotool and then in your ~/.xmonad/xmonad.hs config file you can configure additionalKeys like this:

import XMonad.Util.EZConfig

...

main = xmonad $ defaultConfig { ... }
                 `additionalKeys`
                 [ ((mod1Mask, xK_c), spawn "xdotool key alt+c")
                 , ((mod1Mask, xK_v), spawn "xdotool key alt+v")
                 , ((mod1Mask, xK_x), spawn "xdotool key alt+x")
                 ]
share|improve this answer
    
I had already tried that, but for some reason xdotool doesn't work when it is called from xmonad. –  Eren Tantekin Feb 25 '12 at 9:59

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.