blob: 583746455d5424fbafa175006ae5876b47adca9c (
plain) (
blame)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
#!/bin/dash
load_layout () {
if test -f "${XDG_RUNTIME_DIR}/.setkeys_layout"; then
cat "${XDG_RUNTIME_DIR}/.setkeys_layout"
fi
}
save_layout () {
printf '%s\n' "$1" > "${XDG_RUNTIME_DIR}/.setkeys_layout"
}
if test "$1" = "greek"; then
layout=gr
elif test "$1" = "swedish"; then
layout=se
elif test "$1" = "english"; then
layout=en_US
elif test "$1" = "toggle"; then
layout="$(load_layout)"
if test "$layout" = se; then
layout=gr
else
layout=se
fi
elif test $# = 0; then
layout="$(load_layout)"
else
layout="$1"
fi
if test -z "$layout"; then
layout=se
fi
save_layout "$layout"
setxkbmap \
-rules evdev \
-model pc105 \
-layout "$layout" \
-variant '' \
-option '' \
-option terminate:ctrl_alt_bksp,compose:rwin,keypad:future \
-types complete \
-compat complete \
-synch
{
# Assign LeftCtrl to CapsLock
printf '%s\n' 'keycode 66 = Control_L Control_L Control_L Control_L'
# Assign LeftHyper to LeftCtrl
printf '%s\n' 'keycode 37 = Hyper_L Hyper_L Hyper_L Hyper_L'
# Assign remove layout switch from LeftShift
printf '%s\n' 'keycode 50 = Shift_L Shift_L Shift_L Shift_L'
if test -z "${NO_UNICOMP}"; then
# Unicomp's newer versions of New Model M swapped AltGr and RSuper
# making it a torture device for even someone with as big hands as mine
if (cat /sys/class/input/*/name; cat "${XDG_RUNTIME_DIR}/vmhostkeyboards" ) 2>/dev/null | grep Unicomp > /dev/null; then
# Assign Compose to AltGr
printf '%s\n' 'keycode 108 = Multi_key Multi_key Multi_key Multi_key'
# Assign AltGr to RightSuper
printf '%s\n' 'keycode 134 = ISO_Level3_Shift ISO_Level3_Shift ISO_Level3_Shift ISO_Level3_Shift'
fi
fi
cat <<EOF
clear Shift
clear Lock
clear Control
clear mod1
clear Mod2
clear Mod3
clear Mod4
clear Mod5
add Shift = Shift_L Shift_R
add Control = Control_L Control_R
add Mod1 = Alt_L Meta_L
add Mod2 = Num_Lock
add Mod3 = Hyper_L
add Mod4 = Super_L
add Mod5 = ISO_Level3_Shift
EOF
} | xmodmap -
if cat /sys/class/input/*/name | grep Unicomp > /dev/null; then
# Turn off numlock LED
input="$( (grep Unicomp /sys/class/input/*/name; cat "${XDG_RUNTIME_DIR}/vmhostkeyboards" | grep Unicomp || :) 2>/dev/null | \
sed 's|^/sys/class/input/\(.*\)/name:.*$|\1|g' | sed 1q)"
if ! echo 0 | sponge "/sys/class/leds/${input}::numlock/brightness" 2>/dev/null; then
if isfg; then
# TODO do at boot
asroot chown ${USER}:${USER} "/sys/class/leds/${input}::numlock/brightness"
echo 0 | sponge "/sys/class/leds/${input}::numlock/brightness"
fi
fi
fi
# Esc = 9
# F1…F10 = 67…76
# F11…F12 = 95…96
# § = 49
# 1…9 = 10…18
# 0+´ = 19…21
# Backspace = 22
# Tab = 23
# qwertyuiopå¨ = 24…35
# Enter = 36
# CapsLock = 66
# asdfghjklöä = 38…48
# ' = 51
# LeftShift = 50
# < = 94
# zxcvbnm,.- = 52…61
# RightShift = 62
# LeftCtrl = 37
# LeftSuper = 133
# Alt = 64
# Space = 65
# AltGr = 108
# RightSuper = 134
# Menu = 135
# RightCtrl = 105
# SysReq = 107
# ScrlLock = 78
# Break = 127
# Insert = 118
# Home = 110
# PageUp = 112
# Delete = 119
# End = 115
# PageDown = 117
# Up = 111
# Left = 113
# Down = 116
# Right = 114
# NumLock = 77
# Num/ = 106
# Num* = 63
# Num- = 82
# Num7 = 79
# Num8 = 80
# Num9 = 81
# Num+ = 86
# Num4 = 83
# Num5 = 84
# Num6 = 85
# Num1 = 87
# Num2 = 88
# Num3 = 89
# NumEnter = 104
# Num0 = 90
# Num, = 91
|