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.
I know it's silly but as a workaround you could just autostart
xmodmap ~/.Xmodmap
.Also you could check
/etc/gdm/Xsession
for the lineusermodmap="$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
.Late to the party, but this drove me nuts as well ; and, stubborn as I am, giving up was not an option.
Basically this is what I tried, (as my user, or root if necessary)
(Actually, adding the
xmodmap
command to~/.bashrc
worked, but it requires to start a terminal each time after login)A few years ago(?),
xkb
was chosen to deal with keys mapping and configuration (interfacing with X), butxmodmap
might also request key related changes to X, afterxkb
did its work during the X session initialization.The problem is when should these xmodmap settings happen?
It seems those above files are processed too early in the process, and either X was not ready to accept xmodmap changes, or xkb would overwrite them.
Note: I added some "tracking" to these files to ensure they were actually running at some time!
A solution that seems to work
I was not keen to add a
.desktop
file initially (a simple one line script had to be enough), but that works, so here it is.The solution comes from How to remap or swap special keyboard keys in Linux? "solution 1"
Basically create
~/.config/autostart/my-xmodmap.desktop
file, and put in it:replace
me
with your username (note that I didn't bother to try~/
or$HOME
that may work equally well in place of/home/me
, and the full path of xmodmap is likely not necessary...), and add the exec bitThe xmodmap commands have to be in a
~/.Xmodmap
file in this case (or use the-e
option, or choose another file name!). Log out and back in.Note that you might create the starting program from "Startup Applications".
Another solution would be to forget xmodmap and learn how to configure
xkb
!Edit (again)
Sometimes, maybe 25% of the logons, the
xmodmap
still seems not working - while the command is actually run (a tracker proves that). The only conclusion I might come to at this time is that thexkb
process does run late in the logon process, and may end after thexmodmap
has run. Looks like a race condition... So, finally, I changed the autostart desktop fileexec
line to(note the
&
)mystart
is a script in a new directorybin
I created that containsand
The script sleeps 5 seconds before to run xmodmap, and tracks when it did run (in the file
/tmp/xmodmap-has-run
).Hopefully that will be all!
Here is, perhaps a better answer then: http://cweiske.de/howto/xmodmap/ar01s06.html
You may have to tweak it a little bit to work for you but the instructions are all there.
Perhaps you have a syntax error in your
~/.Xmodmap
file?Try running:
That should fire an error if there are any.
Unfortunately, this looks like a (very) long standing issue, and it is just because after Gnome 3.6,
xmodmap
support was dropped.This is discussed in Remap keys on GNOME3.8 using xmodmap? and Bug 873656 - .Xmodmap file not loaded by Gnome 3.x .
The solution is to move to
xkb
. There is a bit of help from comment 29 in the second link.I had the same weird problem, trying to start up my
xmodmap
while logging in my session (Ubuntu 13.04). I finally made it work with a.xinitrc
file in my Home folder where I put my command, but with absolute paths to it, that is:/usr/bin/xmodmap /home/MYNAME/.Xmodmap
Then I had to reboot (not just relog) so that it would be executed.