Projekt

Allgemein

Profil

Config keyboard » Historie » Version 2

Jeremias Keihsler, 13.01.2017 09:43

1 1 Jeremias Keihsler
h1. changing keyboard layout
2
3
4
taken from http://askubuntu.com/questions/296155/how-can-i-remap-keyboard-keys
5
6
To simply swap two keys functions: From Terminal run xev and then press F9 which would give something like Terminal window showing F9 KeyPress event
7
8
Doing the same for PrtSc did not give any output in xev for me (or i could not find the "KeyPress event") so i used Argusvision's advice for using the Custom Shortcuts in All Settings but doing so in order to disable PrtSc as screenshot button by reassigning as Shift + Alt then tried pressing again which gave me keycode 107 for PrtSc in xev like so Terminal window showing PrtSc KeyPress event
9
10
Repeating the process for all four keys gave me
11
12 2 Jeremias Keihsler
<pre>
13
F9 = keycode 75
14
PrtSc = keycode 107, action Print
15
F10 = keycode 76
16
Scroll Lock = keycode 127, action Pause
17
</pre>
18 1 Jeremias Keihsler
19
To change a keys function we need to know the keycode of the NEW key being pressed and the "action" of the OLD or existing key for that function.
20
21
Now that we have the key codes for identifying the keys we now make the system do what we want by using xmodmap and as we know F9 has "keycode 75" and PrtSc has the action of "Print" all we need to do is
22
xmodmap -e "keycode 75 = Print"
23
to make the F9 key behave as if the PrtSc key has been pressed. i.e. the keycode stays the same but pressing the F9 key will have different results.
24
Using xev with Scroll Lock also gave
25
Terminal window showing Scroll Lock KeyPress event
26
27
which confirms the "action" for the Scroll Lock key is "Pause" so for making the F10 act as Scroll Lock trying
28
xmodmap -e "keycode 76 = Pause" should give the desired results.
29
That is until you log out or shutdown etc so what we have to do after confirming the commands
30
xmodmap -e "keycode 75 = Print"
31
32
xmodmap -e "keycode 76 = Pause"
33
34
do give the desired results is sort out SysRec which is modified PrtSc and swap over the other buttons so we do not have multiple instances of same key action . Adding
35
xmodmap -e "keycode 107 mod1 = F9 Sys_Req"
36
should swap F9 to where PrtSc was keeping the modified SysReq (Alt + PrtSc) again we can use xev to help verify this.
37
Swapping the Scroll Lock and F10 buttons is easier xmodmap -e "keycode 127 = F10"
38
39
After making sure that when running
40
xmodmap -e "keycode 75 = Print"
41
42
xmodmap -e "keycode 107 mod1 = F9 Sys_Req"
43
44
xmodmap -e "keycode 76 = Pause"
45
46
xmodmap -e "keycode 127 = F10"
47
does indeed do what is intended all that is left to do is get this happening at startup time. To do this run
48
xmodmap -pke|egrep  -e '(F9|Print)'
49
which gave me
50
some more text
51
we are only interested in the keycodes 75 and 107. Do the same for
52
xmodmap -pke|egrep  -e '(F10|Pause)'
53
which gave me
54
even more text
55
and we are only interested in the keycodes 76 and 127.
56
57
Create a new text document with your favourite text editor copy and paste the relevant information
58
59 2 Jeremias Keihsler
<pre>
60
keycode 75 = Print NoSymbol Print
61
keycode 107 = F9 Sys_Req F9 Sys_Req
62
keycode 76 = Pause NoSymbol Pause
63
keycode 127 = F10 NoSymbol F10
64
</pre>
65 1 Jeremias Keihsler
66
naming the file as .Xmodmap and saving it in your Home directory would allow you to run the changes simply by logging on after rebooting.
67
68
In my actual case i exchanged Home with Prior and End with Next:
69
keycode 112 = Home
70
keycode 117 = End
71
keycode 110 = Prior
72
keycode 115 = Next
73
74
<pre><code class="bash">
75
xmodmap -e "keycode 112 = Home"
76
xmodmap -e "keycode 117 = End"
77
xmodmap -e "keycode 110 = Prior"
78
xmodmap -e "keycode 115 = Next"
79
</code></pre>