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.

This is my procedure every time I start my computer:

xkeycaps -kbd mac

I then swap the downarrow and left shift keys, which in fact switches the Left-Command and Left-Option on my Mac keyboard.

Try as I may, I can't figure out how to automate this. I've tried using its xmodmap export feature, I've tried writing xmodmap files myself, but nothing has any effect.

I'm looking for a way to make this key exchange from the CLI so I can put it in a script.

share|improve this question

1 Answer 1

You can use xmodmap.

xmodmap -pke > current.config

saves your current keyboard config to the file current.config. You can open this file in an editor and make your changes. You can read the config with the command

xmodmap current.config

You can also this command in any script.

share|improve this answer
    
Perhaps more usefully, xmodmap -pke >oldmap, then do the xkeycaps thing, then xmodmap -pke | diff oldmap - to see what changed. -pke won't catch modifier map changes, though, and there's no -pme equivalent so that part will have to be translated manually. –  geekosaur Apr 25 '11 at 16:22
    
I did this procedure. It left a sensible diff between the new and old configs. However, running xmodmap on the new config (after a reboot) had no effect. –  Yuvi Masory Apr 26 '11 at 23:55

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.