Why won't my xmodmap command run on startup/login?
I want to run this command every time I log in (or every time I start up, if that doesn't work): xmodmap -e 'keysym Delete = Menu' -e 'keysym Menu = Delete'
I've tried many things. I put the command in System > Preferences > Startup Applications
. I put it in a .sh
file, marked it chmod +x
and put that file in System > Preferences > Startup Applications
. I put the script in /etc/init.d
. I put the commands in ~/.profile
. Nothing seems to work.
Finally, I put this in my ~/.profile
:
touch test1
xmodmap -e 'keysym Delete = Menu' -e 'keysym Menu = Delete'
touch test2
Both test1 and test2 get created, but the keys are still not remapped. If I just copy/paste the command and run it manually, it works fine. But it won't run on login. Any ideas?
Solution 1:
~/.profile
runs early in the login sequence. If your desktop environment configures a keyboard layout, it can overwrite the settings you've just loaded.
Put your settings in a file called ~/.Xmodmap
:
keysym Delete = Menu
keysym Menu = Delete
Under the default Gnome environment in Ubuntu 10.04, the next time you log in, you will be prompted as to whether to load ~/.Xmodmap
. Load it, and tick “don't ask me again”. Then your .Xmodmap
will be applied after the default settings.
Solution 2:
I found that in the place in Gconf-Editor mentioned above the name of your revised keyboard layout should appear twice, once under "known_file_list" and once under "update_handlers". As to why Ubuntu sometimes puts in the latter entry, and sometimes doesn't... well, it keeps you on your toes, doesn't it?
Incidentally, after a lot of research I used the above tweak to re-assign the Left Windows key. I put the following statement in my own keyboard layout to make it duplicate the Left Arrow key:-
keycode 133 = 0xFF51
(Check that those are the right codes for you by going into xev and pressing first one key then the other.)
It's only a little point, but while I'm on the Internet it gives me a convenient "Back" key - Alt+Win with the left hand. I can do it without looking.
Solution 3:
Some systems look for a file named ~/.Xmodmap
and execute the commands found there. Try putting these lines in that file:
keysym Delete = Menu
keysym Menu = Delete