-
Notifications
You must be signed in to change notification settings - Fork 1
/
tmk.sh
executable file
·148 lines (142 loc) · 2.8 KB
/
tmk.sh
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
#!/bin/bash
tmk=("\n
##############\n
# Tarmak 1\n
##############\n
\n
# Top Row:\n
keycode 18 = j\n
# Middle Row:\n
keycode 36 = n\n
keycode 37 = e\n
# Bottom Row:\n
keycode 49 = k\n
\n
##############"
"\n
##############\n
# Tarmak 2\n
##############\n
\n
# Top Row:\n
keycode 18 = f\n
keycode 20 = g\n
# Middle Row:\n
keycode 33 = t\n
keycode 34 = j\n
keycode 36 = n\n
keycode 37 = e\n
# Bottom Row:\n
keycode 49 = k\n
\n
##############"
"\n
##############\n
# Tarmak 3\n
##############\n
\n
# Top Row:\n
keycode 18 = f\n
keycode 19 = j\n
keycode 20 = g\n
# Middle Row:\n
keycode 31 = r\n
keycode 32 = s\n
keycode 33 = t\n
keycode 34 = d\n
keycode 36 = n\n
keycode 37 = e\n
# Bottom Row:\n
keycode 49 = k\n
\n
##############"
"\n
######################\n
# Tarmak 4\n
######################\n
\n
# Top Row:\n
keycode 18 = f\n
keycode 19 = p\n
keycode 20 = g\n
keycode 21 = j\n
keycode 24 = y\n
keycode 25 = semicolon colon\n
# Middle Row:\n
keycode 31 = r\n
keycode 32 = s\n
keycode 33 = t\n
keycode 34 = d\n
keycode 36 = n\n
keycode 37 = e\n
keycode 39 = o\n
# Bottom Row:\n
keycode 49 = k\n
\n
######################"
"\n
######################\n
# Tarmak 5\n
######################\n
\n
# Top Row:\n
keycode 18 = f\n
keycode 19 = p\n
keycode 20 = g\n
keycode 21 = j\n
keycode 22 = l\n
keycode 23 = u\n
keycode 24 = y\n
keycode 25 = semicolon colon\n
# Middle Row:\n
keycode 31 = r\n
keycode 32 = s\n
keycode 33 = t\n
keycode 34 = d\n
keycode 36 = n\n
keycode 37 = e\n
keycode 38 = i\n
keycode 39 = o\n
# Bottom Row:\n
keycode 49 = k\n
\n
######################"
)
baseMap=$(cat /etc/vconsole.conf | grep -oPi "(?<=keymap=)\S+")
if [ -z "$baseMap" ]
then
baseMap="us"
fi
baseMapFile="$baseMap.map.gz"
template=$(find /usr/share/kbd/keymaps -name "$baseMapFile")
# TODO: make default file/dir in prompt
templateConfirmation(){
read -p "Using $template as template - is this ok? (y/n): " confirm
case "$confirm" in
y|Y|[Yy][Ee][Ss] ) echo "Confirmed. Continuing...";;
* ) read -p "Not confirmed. Enter a file to use or press ^C (CTRL+C) to cancel:$n> " template; templateConfirmation;;
esac
}
templateConfirmation
oldPwd=$(pwd)
targetDir="$(cd $(dirname $template)/.. && pwd)/colemak"
cd $oldPwd
n="
"
targetConfirmation(){
read -p "Target directory for new keymaps is $targetDir - is this ok? (y/n): " confirm
case "$confirm" in
y|Y|[Yy][Ee][Ss] ) echo "Confirmed. Continuing...";;
* ) read -p "Not confirmed. Enter a directory to use or press ^C (CTRL+C) to cancel:$n> " targetDir; targetConfirmation;;
esac
}
targetConfirmation
for i in ${!tmk[@]}
do
((j=$i+1))
cp -i $template "$targetDir/tarmak$j.map.gz"
gunzip "$targetDir/tarmak$j.map.gz"
echo -e ${tmk[$i]} >> "$targetDir/tarmak$j.map"
gzip "$targetDir/tarmak$j.map"
done
echo "All done! Now use \"sudo loadkeys tarmak\$\" (replace \"\$\" with 1-4) to load one of the new keymaps."