How to make a key remap stick through reboots?

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
makkasi

Re: How to make a key remap stick through reboots?

Post by makkasi »

It had really hard time getting through this. :) Sory for my pure English. What I wanted was to remove my Num Lock key
(because a realy don't see why this so f.... key is on the keyboard :x with all numpad num keys it's realy annoying )
and to make it Home key so that I can navigate easier. I did all things that are described by the others :
- using xev to discover my key
- using xmodmap to remap them with some file in my home directory
- it works as long as I logged out and logged in and then again
- i tried using .xinitrc , absolutly pointles , .xprofile and etc. notting works
- the only thing that works was running sh file (that is of course executable ) from the startup programs (Preferences/Startup applications)
- and it works every time I restart my computer end etc.
- till I didn't log out and log in , or lock my screen
- realy :x annoying

Now I'm happy because I found this forum and read three important things:
- first that some users tried very hard and didn't success in finding a way to start something with the start of the system
- second very important thing is that something is overwriting my xmodmap settings
- what we configurate using the settings is not using xmodmap but xkb and every thime we enter into reloading session this xkb probably is recompiling

So I should not use xmodmap but XKB.
Here is some code:

Code: Select all

krasen@krasen-Lenovo-Y50-70 ~ $ setxkbmap -print
xkb_keymap {
	xkb_keycodes  { include "evdev+aliases(qwerty)"	};
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include "pc+us+bg(phonetic):2+inet(evdev)+group(alt_shift_toggle)+terminate(ctrl_alt_bksp)"	};
	xkb_geometry  { include "pc(pc105)"	};
};
krasen@krasen-Lenovo-Y50-70 /usr/share/X11/xkb/keycodes $ grep -r "pc105" ./
./sgi_vndr/indy:    include "sgi_vndr/indy(pc105)"
./sgi_vndr/indy:xkb_keycodes "pc105" {
./evdev:        # Added for pc105 compatibility
So , As you can see with the first command you can find what key codes XKB is using. You can find all xkb files (for linux mint 17) :

Code: Select all

/usr/share/X11/xkb/
Go in the folder keycodes and open your used keycode file (from the command abouve you can see that mine is "evdev"). In this file you can find all keys described one by one. And a little example for how I achiaved my key mapping because it took me about 6 3 hours to figure this out. I wanted to change Num Lock key to be Home key. In the file "evdev" you can see these two rows:
<HOME> = 110;
<NMLK> = 77;

So after my edit it looks like this:
<HOME> = 110;
<HOME> = 77;

It's so simmple but all the time it was more logical for me assignment to happen to HOME and not to the 77. Whatever...
After you edit this file you should delete the compiled files in /var/lib/xkb (delete all .xkm files) and to run again:

Code: Select all

setxkbmap 
so that everything recompiles, and that's it. Now should work without any problems;


EDIT 1:
Doing this change above is actualy will make the HOME key stop working. The first 110 key will not work. Only 77 key will work. So this is only usable if you have broken key. So if you realy want to make it right you should not edit the files in

Code: Select all

.../xkb/keycodes
but the files in

Code: Select all

.../xkb/symbols
from the command:

Code: Select all

setxkbmap -print
you can see that my used symbol files are:
pc , us and bg
So if you want for example to do this change for remaping Num Lock with Home key you should search for NMLK in the pc file and edit it like this

Code: Select all

key <NMLK> {	[ Home 		]	};
If you want to edit keys that are affected by Shift key you should describe all four levels. For example all num lock number keys are affected by shift but I want number 7 to be always Home key no matter if I'm pressing Shift or not so I'm eddititng again the symbols files.
Search for your key in one of the pc,us or bg (in my case) files and edit it.

Code: Select all

key <KP7>  { [	Home,			Home,
			Home,			Home	] };
for more information and to get realy good picture of all this you can read this file for xkb:
http://web.archive.org/web/200904240541 ... kb/xkb.pdf
jiawen
Level 2
Level 2
Posts: 75
Joined: Sun Mar 17, 2013 5:29 pm

Re: How to make a key remap stick through reboots?

Post by jiawen »

Thank you for your reply, makkasi> However, your solution doesn't seem to work persistently. After I tried applying it, something is still something resetting my keyboard to a different layout on an annoyingly frequent basis.

In fact, the problem has gotten worse. My keyboard somehow has started setting itself to a Japanese layout, which is infuriating, because I sometimes am completely unable to type my password to log in. I've tried removing the Japanese keyboard from the keyboard layout options, but the keyboard somehow still comes back to that occasionally. And not even predictably!

It seems like this is a known bug, but nothing is so far getting done about it. This is a complete show-stopper, because it might cause me to be completely unable to log in. In fact, it has caused that in the past (due to caps lock getting turned on in the interval while I was in the process of turning off the caps lock key, meaning that any kind of case-sensitive activity, such as entering a password, was impossible to do... without restarting the machine).

This whole thing continues to make me tear out my hair. I wish it would get addressed.
Locked

Return to “MATE”