-
Notifications
You must be signed in to change notification settings - Fork 0
/
remapLaptopKeyBoard
executable file
·69 lines (57 loc) · 2.28 KB
/
remapLaptopKeyBoard
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
remote_id=$(
xinput list |
sed -n 's/.*AT Translated Set 2 keyboard.*id=\([0-9]*\).*keyboard.*/\1/p'
)
[ "$remote_id" ] || exit
# remap the following keys, only for my custom vintage atari joystick connected
# through an old USB keyboard:
#
# keypad 5 -> keypad 6
# . -> keypad 2
# [ -> keypad 8
# left shift -> left control
mkdir -p /tmp/xkb/symbols
# This is a name for the file, it could be anything you
# want. For us, we'll name it "custom". This is important
# later.
#
# The KP_* come from /usr/include/X11/keysymdef.h
# Also note the name, "remote" is there in the stanza
# definition.
cat >/tmp/xkb/symbols/custom <<\EOF
xkb_symbols "remote" {
# remap 1/exclam key to Katakana with xkb then Disable Katakana Keysym with xmodmap
# make key ONE_LEVEL type to avoid CAPS_LOCK and SHIFT modifiers
key <AE01> { type= "ONE_LEVEL", [ Katakana ] };
# use KeyPad 1 for 1/exclam
key <KP1> { [ 1, exclam ] };
# key <KP5> { [ KP_Right, KP_6, U2192, U21D2 ] };
# key <I129> { [ KP_Down, KP_2, U2193, U21D3 ] };
# key <AD12> { [ KP_Up, KP_8, U2191, U21D1 ] };
# key <LFSH> { [ Control_L ] };
};
EOF
# (1) We list our current definition
# (2) Modify it to have a keyboard mapping using the name
# we used above, in this case it's the "remote" definition
# described in the file named "custom" which we specify in
# this world as "custom(remote)".
# (3) Now we take that as input back into our definition of the
# keyboard. This includes the file we just made, read in last,
# so as to override any prior definitions. Importantly we
# need to include the directory of the place we placed the file
# to be considered when reading things in.
#
# Also notice that we aren't including exactly the
# directory we specified above. In this case, it will be looking
# for a directory structure similar to /usr/share/X11/xkb
#
# What we provided was a "symbols" file. That's why above we put
# the file into a "symbols" directory, which is not being included
# below.
setxkbmap -device $remote_id -print \
| sed 's/\(xkb_symbols.*\)"/\1+custom(remote)"/' \
| xkbcomp -I/tmp/xkb -i $remote_id -synch - $DISPLAY 2>/dev/null
# disable Katakana (after applying xkb to prevent overwrite)
xmodmap -e "keysym Katakana = NoSymbol"