Friday, December 22, 2006

.Xmodmap hex digits

I's a couple of day I'm hacking with xmodmap and keycodes to make my keyboard behave as I expect.

Recently it sprang to my mind that with SuSE 7.1 I used a utility called xkeycaps.

Unfortunately enough xkeycaps generates an .Xmodmap with keycodes expressed as hex numbers, while xev shows code as decimal numbers

This simple ruby oneliner converts an .Xmodmap file with hex codes to one with decimal codes

cat .Xmodmap.hex |
ruby -n -e "if $_ =~ /keycode\s*(0x[A-F0-9][A-F0-9])\s*=\s*(.+?)\n/; puts \"keycode #{$1.hex} = #{$2} \" else puts $_ end">
.Xmodmap.dec
provided you called the hex .Xmodmap '.Xmodmap.hex'.

No comments: