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?

  • don't post the same question on multiple Stack Exchange sites (unless the question is on-topic on both sites and you've waited a long time and not had any good answer on the first site; but then include a link to the original question). Sep 6, 2010 at 21:32
  • @Gilles: Is that the official policy? It seems like if it is on-topic on both sites, then both sites can benefit from it. But if this has already been discussed and decided, I will be careful in the future.
    – Matthew
    Sep 18, 2010 at 19:48
  • I thought there was an official FAQ entry about this, but I can't find it. I've asked on meta. Sep 19, 2010 at 13:19

3 Answers 3


Put it in ~/.Xmodmap. Some distro look for ~/.Xmodmap instead of ~/.xmodmaprc. It works for me on Fedora 16.

  • This is the best solution on debian
    – unloco
    Mar 4, 2018 at 17:40

Depending on your distribution the ~/.xsession file is executed (a shell script) when logging into X. And/or the ~/.Xmodmap file is sourced by an xmodmap process.

The ~/.profile file is only executed by a login shell (with or without X), thus it is not the right place


Put it in ~/.xsessionrc and make sure that /etc/X11/Xsession.options contains allow-user-xsession.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.