I have scoured the web, and I can't seem to get Xmodmap / anything to work properly. I want to swap BOTH my Command keys with my Control key - in essence, inverting what they do currently.
How would I do that?
I tried xmodmap -e "keycode 133 = Control_L"
and corresponding commands for keycodes 134 (right command) and 37 (control left). I even tried these commands, plus xmodmap -pke > ~/.Xmodmap
and xmodmap ~/.Xmodmap
in .xinitrc
.
My end goal is I want HUD / Dash to come up when I click control
and command
to functional control, i.e., control-v
is a commond shortcut to paste, i would click command-v
I figured it out. Put the following in
~/.Xmodmap
:To test, run the command:
To make it run every time, add it to Startup Applications.
This should work on any MacBook Pro; the issue was that Xmodmap was assigning Super_L to the left and right command keys, and Control_L to the left control key. For some reason, by default, Ubuntu thinks that the MacBook Pro has a standard 105 key keyboard (probably thinking about the full Apple Keyboard) but that is wrong. Anyway, I reassigned the keycodes to the right keysims, then assigned the keysims to
control
andmod4
.I just installed Ubuntu 16.04 dual boot on my MBP13" yesterday. For Ubuntu 16.04, here's how i did it:
Step 1: Launch terminal
Step 2: Edit X Keyboard Extension
Step 3: Make the following changes. Ensure your file looks like this:
Step 4: Clear xkb's cache
Step 5 (conditional): If the keys are not swapped after step 4, restart your computer. It worked for me after this.
Hope it helps, good luck!
Go into
System -> Preferences -> Keyboard
Click on the "Layouts" tab and then click the "Layout Options" button.
Click on "Alt/Win key behavior"
Select "Control is mapped to Win keys (and the usual ctrl key).
from http://ubuntuforums.org/showthread.php?t=1293081
Updated for 18.04 since none of the provided answers seemed to work on my system. I did a clean install of 18.04 and attempting to use a wired aluminum apple keyboard. Default behavior of Left Super on English US is mapped to Gnome Desktop Dashboard. Tweak tool had all the necessary settings in an easy to use GUI!
First I swapped the dashboard hotkey to the right side and then under "Additional Layout Options" you can use "Ctrl position/ Swap Left Win with Left Ctrl" to good effect.
Go to system settings and then to keyboard layout, then to options, then to Win/Alt key behavior, and then check the "Meta switches Ctrl" and then in the Ctrl Position check "Ctrl switches Meta" and there you have it!
on 12.04.1 you change this by:
First, going to "System Settings" then clicking on "Keyboard" then "Layout Settings" (in the bottom left), then "Options" in the bottom right, then expanding the "Alt/Win key behavior" tab, then selecting "Control is mapped to win Keys (and the usual Ctrl keys)"
The community Ubuntu help page for Apple keyboards gives the following steps to permanently make this change: (tested 2017-05-27)
To temporarily test it out, you can run
I use a Deck keyboard with Mac keys hooked to a USB switch to switch my keyboard/mouse/camera/microphone between a number of computers, including Mac laptops and Ubuntu boxes. I just wanted the "Apple/Win" key to act like a ctrl key when I was running Ubuntu, so if I hit Apple-C to copy it would work on Ubuntu.
On Ubuntu 20.04:
sudo apt install gnome-tweak-tool
Duplicate of How to swap Command and Control keys with xkb step by step?
In 16.04, here's the way I finally got this to work. Xmodmap doesn't work universally in all apps, gnome tweak tool lacked the function, dconf editing a custom altwin2 key swap (like the main answer here) failed, so I was tearing my hair out until I combined several answers into this complete, simple, and elegant solution:
change it to:
Save.
(I don't know if this is required, but I did it.)
Reboot.