7

I don't understand scripts or how to make them or how to run them. All I want to do is run the command xmodmap -e "keycode 112 = Delete" when my computer starts. When I run this command in terminal, it remaps the PgDn key to be a second Delete key. But then I have to run it again every time I start the computer. How can I do this? I've tried adding it as a line in the rc.local file but it doesn't work.

Aditya
  • 13,256
  • 17
  • 64
  • 95
user118223
  • 81
  • 1
  • 1
  • 4
  • 1
    Specifically for `xmodmap` commands there is another way of doing it: see [my answer here](http://askubuntu.com/questions/54157/how-do-i-set-xmodmap-on-login/211461#211461), but placing it in startup applications is fine as well, as has been suggested. –  Jan 08 '13 at 14:02

2 Answers2

9

You can make it run at boot by adding it in startup applications. Open startup applications from the dash. Click 'Add' and put xmodmap -e "keycode 112 = Delete" in the 'Command' field. Give it a name and comment if you want. Click 'Add' and login again.

enter image description here

Seth
  • 57,282
  • 43
  • 144
  • 200
5

Seth's solution is a high-level solution that works fine as long as you don't change the desktop environment to something more exotic. To be on the secure side you might want to choose a method that acts at a lower level:

Open up a terminal (CTRL + ALT + T) and execute the following command:

echo "xmodmap -e \"keycode 112 = Delete"\" >> $HOME/.bashrc

This appends xmodmap -e "keycode 112 = Delete" to your .bashrc file and thus executes it on each login.

Edit: As Mik pointed out this might not be the best way of setting xmodmap up. See here for a better method.

Glutanimate
  • 21,183
  • 13
  • 100
  • 153
  • 1
    `~/.bashrc` is not read at startup when you login with `lightdm`, but `~/.profile` is; so you could put it in there, or better still do what I suggested [here](http://askubuntu.com/questions/54157/how-do-i-set-xmodmap-on-login/211461#211461). –  Jan 08 '13 at 14:16
  • @Mik I didn't know that. Thanks for pointing it out. I edited my answer accordingly. – Glutanimate Jan 08 '13 at 14:32
  • Nice answer +1. – Seth Jan 08 '13 at 16:17