Friday, November 30, 2007

Eclipse and keycode mapping

Okay, this is take 2 because my first post was unceremoniously 'disappeared'.

My BTS team is getting geared up for writing Unit Tests in JUnit. We're using Eclipse with subclipse for SVN. Two teammates are Windows, one Linux and me on the Mac. Mac's version of Java is Apple's not Sun's so my JRE profile is not compatible with theirs. This means I will be using my Linux VM for the project - getting to know Ubuntu a little better.

Today's the first day of significant coding and I am already frustrated that I have to reach back to use the ctrl key instead of my trusty apple key for shortcuts. Also the tilde key actually produces < and there's no delete functionality (what Mac calls delete is really backspace).

So I have found a solution and here it is:

First, create a file (mine is called wickedCoolKeycodeFinder - you know, so I can always find it again)
and in that file put this:
xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'

chmod +x this file and then run it to produce a neat little window that will tell you what keycode is returned for whatever key you press.

Then, once you know the keycodes of the keys you want to map, create a file called .xmodmaprc and in that file I put:

!this sorts out the apple key + backspace to do delete
keycode 113 = BackSpace Terminate_Server Delete
! map tilde and grave
keycode 49 = grave asciitilde
!map apple key to ctrl
remove Control = Control_L
keycode 115 = Control_L
keycode 116 = Control_L
add Control = Control_L

Now I just need to figure out how I can get my two-finger scrolling on the touchpad to work and I'll be a Linux user forever!

No comments: