Apple’s X11 Keymap and virt-manager 31

Posted by peter on June 01, 2009

Apple’s default X11 key mapping causes trouble when using virt-manager on the local X server. For reasons unknown to me, Apple maps the option/alt key to Mode_switch, meaning that when virt-manager grabs the cursor, it’ll never let go, as there’s no way of sending Ctrl+Alt to it- apparently it works explicitly off of keysyms instead of mod maps. It’s been long enough since I’ve dealt with X11 configuration issues that I had to do a little hunting to figure things out, so I figured I’d throw my solution up here.

On the machine where you’ll be running your X server (your mac), stick this in ~/.Xmodmap

clear Mod1
keycode 66 = Alt_L
keycode 69 = Alt_R
add Mod1 = Alt_L
add Mod1 = Alt_R

This will make the control keys on your keyboard emit (I think) more sensible events, while keeping Mod1 in the same place. Finally, no more restarting X11 when you want to break free of virt-manager.


UPDATE: The above still works, but it turns out there’s a better way. XQuartz, the open source project that eventually gets rolled back upstream to Apple, has a setting in preferences to switch between Apple default behavior and what the .Xmodmap above will get you. It’s also got other improvements, such as working properly with Spaces. Use it instead.