Ubuntu – Why won’t the ~/.Xmodmap file load on login

keyboardxmodmap

I created the following ~/.Xmodmap file as per this answer.

keysym Delete = Menu
keysym Menu = Delete

clear Lock
keycode 0x42 = Escape

In other words, swap Delete and Menu, and make Caps Lock an additional Escape.

The next time I logged in, Ubuntu asked me if I wanted to load ~/.Xmodmap as expected. I loaded it, but nothing happened (either then or on subsequent logins). If I manually run xmodmap ~/.Xmodmap, it works as expected.

I know that this worked early in the 10.10 beta, but it's failing on my fresh 10.10 install. I haven't tried in on anything earlier than 10.10. Any ideas?

Edit: I put some debugging statements in /etc/gdm/Xsession to make sure ~/.Xmodmap was loading, and everything magically started working. I didn't change anything except adding some echos, and it's still working now that I reverted my changes and restarted again. Strangest thing I ever saw.

One thing I realized is that the "remap Caps Lock to Escape" part of the Xmodmap was always working. It was just the Delete/Menu swap that failed. I'll leave this question open for now in case anyone else has the same problem, since I don't actually know why the problem stopped.

Best Answer

I know it's silly but as a workaround you could just autostart xmodmap ~/.Xmodmap.

Also you could check /etc/gdm/Xsession for the line usermodmap="$HOME/.Xmodmap" and if it isn't there just append it at the end of the file. If you're the only user of the system just put your changes into /etc/X11/Xmodmap.