13

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?

Matthew
  • 5,417
  • 4
  • 19
  • 11
  • don't post [the same question](http://superuser.com/questions/185345/why-wont-my-xmodmap-command-run-on-startup-login) 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). – Gilles 'SO- stop being evil' Sep 06 '10 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 '10 at 19:48
  • I thought there was an official FAQ entry about this, but I can't find it. I've [asked on meta](http://meta.unix.stackexchange.com/questions/146/policy-on-multiposting). – Gilles 'SO- stop being evil' Sep 19 '10 at 13:19

3 Answers3

6

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

Bank Qian
  • 61
  • 1
  • 1
5

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

maxschlepzig
  • 56,316
  • 50
  • 205
  • 279
1

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

Peter Eisentraut
  • 2,142
  • 1
  • 16
  • 11