I love the new Ubuntu 12.04 Precise Pangolin. Unity – and the graphics drivers – have finally reached a stability that satisfies me and let me keep GNU/Linux as solo operating systems on my Macbook Pro 6,2.

What drives me crazy is the default keyboard mapping, surely not thought for who owns an Apple computer.

First, the Unity Launcher (a.k.a. Dash) default shortcut is the Super key (or Win key). This key corresponds to the cmd key on Apple keyboards.
Under Mac OS X, the combination cmd+space opens Spotlight, while cmd+c, cmd+v are for Copy&Paste. That is, the cmd key is a supercharged ctrl key.

I spent some time to search the best combinations to reproduce this behavior under Ubuntu.
Here is what I managed to create:

  • I swapped the left ctrl and the left/right cmd keys. That is, cmd becomes ctrl and ctrl becomes cmd
  • After the first modification, it becomes unconvenient to open Dash with the ctrl key. Therefore, I changed Unity Launcher key to cmd+space. This (sort of) emulates OS X behavior.

To implement the first tweak, create the file ~/.Xmodmap with the following content:

Logout and login again.
Congratulations, you have the swapped keys. Ubuntu should already take care to load the file automatically.

It is important to not manually load the .Xmodmap file. It may result in a double application of the mappings, resulting in a re-swap of the keys.

To achieve the second tweak, install the package compizconfig-settings-manager.
Open it using the ccsm command, or search for it in Dash.
Find Ubuntu Unity Plugin->Behavior->Key to show the launcher and change it to <Primary>space, using the Grab key combination button. It may be also shown as <Control><Primary>space.

You can now have a behavior similar to Mac OS X in Ubuntu 12.04. You can change the virtual desktop using cmd+alt+arrow. You can cut, copy, and paste using cmd+x, cmd+c, and cmd+v. You can open the Unity launcher with cmd+x.

I hope that this little how-to can help frustrated Apple users who want to embrace GNU/Linux freedom.

(Featured Image credits: Marco Antonio Islas Cruz)

Author: dgraziotin

Dr. Daniel Graziotin received his PhD in computer science, software engineering at the Free University of Bozen-Bolzano, Italy. His research interests include human aspects in empirical software engineering with psychological measurements, Web engineering, and open science. He researches, publishes, and reviews for venues in software engineering, human-computer interaction, and psychology. Daniel is the founder of the psychoempirical software engineering discipline and guidelines. He is associate editor at the Journal of Open Research Software, academic editor at the Research Ideas and Outcomes (RIO) journal, and academic editor at the Open Communications in Computer Science journal. He is the local coordinator of the Italian Open science local group for the Open Knowledge Foundation. He is a member of ACM, SIGSOFT, and IEEE.

24 thoughts on “Configure the keyboard for your Macbook and Ubuntu 12.04 (and 12.10)”

  1. I tried doing this as well but it just doesn’t fit the keyboard scheme in Ubuntu so I just reverted back. I somehow already have a feel for the keyboard shortcuts anyway since I’ve used both Windows and mac.

    1. In which sense it does not fit the keyboard scheme? Are there no more working keys on your keyboard after my instructions?
      By the way, I re-installed Ubuntu 12.04 today and I can confirm this tutorial is working for me.

  2. Hello, does the cmd+space work with Gnome 3 instead of Unity? The first tweak worked great but I cannot get the second to work. Any help appreciated.

  3. I’m using a Mac keyboard on Linux Mint 13 – Mate. I selected an option for the command key to act like a control key. This is OK for most things, but in Terminal it doesn’t work because it does a ^C. How can I get this to work so it also allows me to do COPY/PASTE using the Command key in the Terminal program? Thanks!

    1. The ^C you see is what should happen if the mapping has been successful. CTRL+C (or ^C) in a terminal is for sending a SIGINT signal to the active program (i.e., to kill it).
      This behavior is the same under OS X and GNU/Linux. However, Apple Computers have both the CTRL and the CMD keys. That is why you can have this very convenient COPY/PASTE thing in the Terminal program.
      I do not think that this is implemented in any GNU/Linux desktop environment. Try to follow the instructions posted here. They may work for you.

    2. Edward – can you tell me where that option is / which keyboard layout I can find it in? That’s exactly what I’m looking for!

  4. Brilliant post! I think it proved very useful for me in making more out of keyboard functionality. Next time, you should post on mouse gesture functionality on the mac.

    Anyway, the trick worked great. But although my left cmd button works, the right cmd button doesn’t. How can I solve this? Thanks.

    1. Hello John, it works for me with both CMD keys.
      Can you double check if the the .Xmodmap files contains these two lines?

  5. I had this working for a long time, but now Quantal Quetzal do not seem to load .Xmodmap on login and I had to load the file manually on the command line. Further, sometimes after suspend/resume I lost the configuration (not always) and have to run the command again. Any ideas?

  6. For me the .Xmodmap file is not loaded when I restart (the system logged in automatically) on Quantal.

    Also, I have this little (but really annoying) problem: cmd+s (for saving a file) does not work as expected, instead it starts echo, the workspaces overview. I tried to disable this via the compizconfig manager but no luck.

    Any ideas?

    1. There are reports on strange behaviors from other users as well. Is only cmd+s not working? Do shortcuts for copy and paste (cmd+c, cmd+v) work? That would look rather strange.

  7. This is excellent, thanks!

    One thing I’m not sure about though, is how to get the hash key working. I found a way, which involved modifying the 3rd level key mapping in the keyboard layout, but then it messes up the above fix.

    Anyone know anything about this?

  8. Some keys are not working as expected on my dual boot ubuntu. For typing out a double quote, i need to press shift+2 , which is usually @, but the keys have reversed her.
    The shift+3 doesnt give me hashtag but this Β£.
    Lots of other characters are acting messed up too.
    I still can’t find backslash. The original backslash key prints ~
    Very very annoyed! please help!

    1. sounds like you have a wrong layout for your keyboard. For example, Italian keyboards have double quotes located at SHIFT+2. This is something you should fix before applying what is written in this post. Look for the settings of your desktop environment.

Leave a Reply

Your email address will not be published. Required fields are marked *