How to remap key on startup

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help

How to remap key on startup

Postby jgradyc on Tue Apr 23, 2013 9:03 am

I want to switch the PgUp and the Delete keys. I have done this successfully on my laptop from the terminal, but I have not been successful in getting these commands to automatically run on startup. To remap the keys, I used these commands.

xmodmap -e "keycode 112 = Delete"
xmodmap -e "keycode 119 = Prior"

This successfully switches the keys, but I have to re-enter these commends after rebooting. I then tried to follow instructions to create something called a script to run at start to make these changes permanent. The instructions to do this are everywhere on the internet, but none seem to be the same! :?: I tried duplicating some of the instructions, but they didn't work.

I guess my question is: How do I create this script or whatever it's called and how do I save it to autorun every time the computer boots up? Thanks.
jgradyc
Level 1
Level 1
 
Posts: 38
Joined: Sun Apr 07, 2013 7:54 pm
Location: Nashville, TN

Linux Mint is funded by ads and donations.
 

Re: How to remap key on startup

Postby bigj231 on Tue Apr 23, 2013 9:12 am

I think what you're looking for is the rc.local file. You can view it with:
Code: Select all
nano /etc/rc.local
It shouldn't have any commands unless you changed it. Just add those commands to that file, before the "exit 0" and they will be run at startup. You will have to open it with root privileges to edit it. You can also use gedit instead of nano.
Running on a 4-slot toaster @ 60Hz
User avatar
bigj231
Level 5
Level 5
 
Posts: 793
Joined: Fri Feb 26, 2010 10:16 am
Location: Middle of Nowhere

Re: How to remap key on startup

Postby jgradyc on Tue Apr 23, 2013 10:31 am

Thanks. I found another approach that was sooooo easy!! (Note: in the following instructions, I had already determined the keycode number and names of the Delete and PageUp keys.)

In Linux Mint 14...
1. Click menu
2. Click preferences
3. Scroll down list to Startup Applications... click on Startup Applications
4. On the new window that opens up, click "add"
5. On the new window that opens, put a descriptive name in "Name". I entered "Remap Prior to Delete"
6. In Command box, I entered: xmodmap -e "keycode 112 = Delete"
7. In Comments box, I entered: This remaps the PageUp key to a Delete key on startup
8. Next, I clicked "add" to close that window.

***NOTE*** Keycode 112 is the Page Up keycode on my keyboard. Your keyboard might be different. You have to find the keycode for each key using the XEV command.

Then, I repeated steps 4 through 8 as follows
Name: Remap Delete to Prior
Command: xmodmap -e "keycode 119 = Prior"
Comments: This remaps the Delete key to be a PageUp key
Click "add"

***NOTE*** Keycode 119 is the Delete keycode on my keyboard. Your keyboard might be different. You have to find the keycode for each key using the XEV command.

Then, click "close" to close the window.

When I rebooted, it worked fine.
jgradyc
Level 1
Level 1
 
Posts: 38
Joined: Sun Apr 07, 2013 7:54 pm
Location: Nashville, TN

Re: How to remap key on startup

Postby jgradyc on Tue Apr 23, 2013 11:33 am

bigj231 wrote:I think what you're looking for is the rc.local file. You can view it with:
Code: Select all
nano /etc/rc.local
It shouldn't have any commands unless you changed it. Just add those commands to that file, before the "exit 0" and they will be run at startup. You will have to open it with root privileges to edit it. You can also use gedit instead of nano.

Thanks again. I'm pretty sure this is what I did a few months ago before I reinstalled Linux Mint. I just couldn't find a reference to gedit \etc\rc.local

I'll remember this next time I have to add a script to run automatically. Thanks again.
jgradyc
Level 1
Level 1
 
Posts: 38
Joined: Sun Apr 07, 2013 7:54 pm
Location: Nashville, TN

Re: How to remap key on startup

Postby bigj231 on Tue Apr 23, 2013 10:14 pm

You can use nano on almost any system, that's why it's often listed in tutorials. KDE systems will not have gedit, so you could use kate instead. A lot of people swear by vi, at least as many swear at it. Same with emacs.
You can use whatever text editor you want, but gedit or kate are easiest for small to middling edits IMO.
Running on a 4-slot toaster @ 60Hz
User avatar
bigj231
Level 5
Level 5
 
Posts: 793
Joined: Fri Feb 26, 2010 10:16 am
Location: Middle of Nowhere


Return to Newbie Questions

Who is online

Users browsing this forum: AUserInEssex, Bing [Bot], Pierre and 20 guests