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.

I switch back and forth between two computers constantly:

  • OSX Snow Leopard
  • Ubuntu 10.10

I'd like to be able to make Ubuntu use the same keyboard shortcuts as OSX System Wide, for the following keyboard sequences only (ie I don't want to make Ctrl act like Super)

  • Super+C -> Copy

  • Super+V -> Paste

  • Super+T -> Open a new tab in whatever browser I'm in.

  • Super+W -> Close a tab in whatever browser I'm in.

So in short, is there anyway for me to map just these keyboard sequences to the following, system wide ?

  • Super+C -> Ctrl+C
  • Super+V -> Ctrl+V
  • Super+T -> Ctrl+T
  • Super+W -> Ctrl+W

I know there are ways for me to do this for vim, and Firefox, and I'm sure specifically for most applications... but I would prefer to have to do this just once and have it work that way system wide!

I'm using a standard PC keyboard, that is "Generic 105 key (intl) PC" on Ubuntu. I'm also using the same keyboard on my Mac mini.

share|improve this question
    
If you got this dialed in for all the Mac keyboard shortcuts, sharing your config file would be terrific! Thanks –  Dolan Antenucci Apr 19 '13 at 16:58
    
hey! I wish I still did, but I'm working exclusively on Mac's now, as I've moved jobs ;-) So I don't have my old config around anywhere... –  brad parks Apr 19 '13 at 17:13

6 Answers 6

up vote 13 down vote accepted

If you install the xautomation package, you can add a command in System/Preferences/Keyboard Shortcuts/Custom like:

xte "keyup Meta_L" "keyup c" "keydown Control_L" "key c" "keyup Control_L"

and map that to Meta-C.


Alternative Solution:

Install AutoKey (apt-get install autokey-gtk) and set a phrase to:

Phrase Text: <ctrl>+C (actually type out the <ctrl>+ here)
Paste Using: Keyboard
Abbreviation: None
Hotkey: <super>+v
Window Filter: None
share|improve this answer
    
hey! this looks very promising... i've installed, and can run the above xte command from the terminal, and it outputs "^C" in the terminal... which looks good to me! but when i map it in Keyboard Shortcuts, it doesn't do anything... I tried mapping another program to Meta-C, and it works fine (ie launches fine when I press Meta-C). I also tried specifying the full path to xte (/usr/bin/xte) and that didn't work either... can you try this on your system and see if it works? thanks! –  brad parks Nov 6 '10 at 1:18
    
So xte sends the key codes correctly, but apparently applications see the combination of the shortcut and the keypresses sent by xte (e.g. Meta-Control-C). I've updated my answer to simulate releasing the shortcut keys before sending the key presses. –  cscarney Nov 6 '10 at 5:18
    
doesn't work for me even with keyup –  hasenj Nov 6 '10 at 6:54
2  
On quick check it works for me, but I've found a solution that will probably be more reliable than xte (even if you get it working). Check the revised answer. –  cscarney Nov 6 '10 at 14:09
    
hey! thanks @cscarney! your "Alternative Solution" for AutoKey totally works! thanks a ton for your continued effort on this! –  brad parks Nov 8 '10 at 17:29

To expand on cscarney's AutoKey hint, I am developing my AutoKey configuration to achieve all this in Ubuntu (OS X-like <cmd>+c, <cmd>+v, ... Emacs-style <ctrl>+f, <ctrl>+b, ...) in my dotfile repo.

I don't use basic phrases (where window filtering is currently broken), but Python scripts, to be able to disable AutoKey in apps such as Emacs, Eclipse, Vim, gnome-terminal ... where I don't want to mess up the existing shortcuts.

You can check out the README on the bottom for instructions on how to set it up.

share|improve this answer

This is an easy task once you know how to do it.

1) Check the keycode of yours key. Run this program at terminal.

xev


At this example, the terminal shows that the keycode for my k is "45".

2) Change them as you like creating this file:

gedit ~/.Xmodmap

It's contents should look like this example:

keycode 64 = Alt_L Meta_L Alt_L Meta_L
keycode 108 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift

(Change the keycode number as needed - look at step "1")

Ilustration:
(Obs.: if I want to change my k I should use "keycode 45" as showed at step "1").

4) Logout and log back in or reboot or run this:

xmodmap ~/.Xmodmap

Hope you enjoy ;-)

share|improve this answer

There is a way to map Ctrl to Win/Super key:

  1. go to system->preferences->keyboard,

  2. open tab Layouts,

  3. click Options...,

  4. open Alt/Win key behavior,

  5. and select Control is mapped to Win keys

And for console there is a forum post how to do that here.

For more digging check general Linux keyboard HOWTO here.

regards :P

share|improve this answer
    
hey @danizmax - thanks for the reply... but I'd specifically like to avoid changing the complete behaviour of Ctrl... I find it screws with other things if I do... I'd really like to map just the keyboard shortcuts that I mentioned in the post... thanks though! –  brad parks Nov 4 '10 at 0:00
    
Well the Ctr+ stays as it is. It only duplicates all Ctrl+ to Super+ so you just add the behavior. Unless you really really wanna change only those you mentioned, you'll have to do a lot of digging with xmodmap and loadkeys. I've added the link to the general Linux keyboard HOWTO. Hope it helps :P –  danizmax Nov 4 '10 at 11:40
    
This was the easiest solution from all proposed. –  Datageek Mar 16 '13 at 16:21

I don't have Ubuntu to hand (Mac's here, Ubu's at the office) but I use a Mac keyboard there and for the same reasons as you, wanted to do this.

First thing is to make sure your keyboard was installed as a Mac keyboard. I think you can change this in system->preferences->keyboard. While you're there one of the tabs will get you to a key mapping page where you can set up how the cmd key works.

Like I say, I can't remember exactly - I can point to the bits on my screen here, but that doessn't work because I'm not there.

If you're still stuck tomorrow, I'll look again.

share|improve this answer
    
system->preferences->keyboard->layouts->options –  Leo Oct 29 '10 at 8:27
    
hi leo... i'm not using a Mac keyboard with Ubuntu though... I'm using a standard PC keyboard, ie "Generic 105 key (intl) PC" did try switching my "keyboard model" to Vendor Apple / Model Apple but that didn't seem to make any difference.... I also tried Vendor Apple / Model Macbook and that didn't seem to change anything either... –  brad parks Oct 29 '10 at 12:11
    
and for what it's worth, I use the exact same PC keyboard on my macmini as well, as I bought it second hand and it didn't come with a mac keyboard. thanks again. –  brad parks Oct 29 '10 at 12:17

I am not sure if this is the answer you are really looking for, but it seems that you can do this by manually. I do not have a ubuntu box in front of me at the moment to try this, but How To Geek has a tutorial for this that may work.

share|improve this answer
    
i took a look at this, and can't see how to get it to work... It looks like it maps to the same options available in "System/Preferences/Keyboard Shortcuts/Custom".... For example, how would I get it to paste using this approach? It looks to me like I can only configure it to run applications... thanks.... –  brad parks Oct 29 '10 at 12:31
    
@brad you are correct, I did not read it carefully enough. I'll keep looking as I would like to do this also. –  jschoen Oct 29 '10 at 19:00

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.