aboutsummaryrefslogtreecommitdiff
path: root/layouts/community/ergodox/algernon/tools
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/community/ergodox/algernon/tools')
-rw-r--r--layouts/community/ergodox/algernon/tools/heatmap-layout.ADORE.json486
-rw-r--r--layouts/community/ergodox/algernon/tools/heatmap-layout.Dvorak.json477
-rwxr-xr-xlayouts/community/ergodox/algernon/tools/hid-commands113
-rwxr-xr-xlayouts/community/ergodox/algernon/tools/log-to-heatmap.py342
-rwxr-xr-xlayouts/community/ergodox/algernon/tools/text-to-log.py106
5 files changed, 0 insertions, 1524 deletions
diff --git a/layouts/community/ergodox/algernon/tools/heatmap-layout.ADORE.json b/layouts/community/ergodox/algernon/tools/heatmap-layout.ADORE.json
deleted file mode 100644
index e09efecc4..000000000
--- a/layouts/community/ergodox/algernon/tools/heatmap-layout.ADORE.json
+++ /dev/null
@@ -1,486 +0,0 @@
1[
2 {
3 "backcolor": "#ffffff",
4 "name": "ErgoDox - algernon's layout: Heatmap",
5 "author": "Gergely Nagy <kbd@gergo.csillger.hu>",
6 "notes": "See [here](https://github.com/algernon/ergodox-layout#readme) for the QMK keymap source.",
7 "switchMount": "cherry",
8 "switchBrand": "gateron",
9 "switchType": "KS-3-Tea",
10 "pcb": true,
11 "css": ".keyborder { -webkit-filter: blur(5px); filter: blur(5px); } .keytop { -webkit-filter: blur(10px); } .keylabels { border: 1px solid black; }"
12 },
13 [
14 {
15 "x": 3.5,
16 "fa": [
17 0,
18 0,
19 2
20 ]
21 },
22 "*\n5\nF5",
23 {
24 "x": 10.5,
25 "a": 4,
26 "fa": [
27 0,
28 0,
29 2
30 ]
31 },
32 "#\n4\nF4"
33 ],
34 [
35 {
36 "y": -0.875,
37 "x": 2.5
38 },
39 "@\n7\nF7",
40 {
41 "x": 1
42 },
43 "^\n3\nF3",
44 {
45 "x": 8.5
46 },
47 "!\n2\nF2",
48 {
49 "x": 1
50 },
51 "&\n6\nF6"
52 ],
53 [
54 {
55 "y": -0.875,
56 "x": 5.5
57 },
58 "$\n1\nF1",
59 {
60 "a": 7,
61 "f": 3
62 },
63 "F11",
64 {
65 "x": 4.5,
66 "f": 3
67 },
68 "Fx",
69 {
70 "a": 4,
71 "f": 3,
72 "fa": [
73 0,
74 0,
75 2
76 ]
77 },
78 "%\n0\nF10"
79 ],
80 [
81 {
82 "y": -0.875,
83 "f": 9,
84 "a": 6,
85 "w": 1.5
86 },
87 "\n\n<i class='kb kb-Multimedia-Play-Pause'></i>",
88 {
89 "f": 3,
90 "a": 4,
91 "fa": [
92 0,
93 0,
94 2
95 ]
96 },
97 " \n9\nF9",
98 {
99 "x": 14.5
100 },
101 " \n8\nF8",
102 {
103 "a": 7,
104 "w": 1.5
105 },
106 "STENO"
107 ],
108 [
109 {
110 "y": -0.375,
111 "x": 3.5,
112 "a": 6
113 },
114 "C",
115 {
116 "x": 10.5
117 },
118 "L"
119 ],
120 [
121 {
122 "y": -0.875,
123 "x": 2.5,
124 "a": 6
125 },
126 "W",
127 {
128 "x": 1,
129 "a": 6
130 },
131 "H",
132 {
133 "x": 8.5
134 },
135 "G",
136 {
137 "x": 1
138 },
139 "P"
140 ],
141 [
142 {
143 "y": -0.875,
144 "x": 5.5
145 },
146 "F",
147 {
148 "a": 4,
149 "fa": [0, 0, 0],
150 "h": 1.5
151 },
152 "{\n(\n[",
153 {
154 "x": 4.5,
155 "h": 1.5
156 },
157 "}\n)\n]",
158 {
159 "a": 6
160 },
161 "M"
162 ],
163 [
164 {
165 "y": -0.875,
166 "f": 3,
167 "a": 4,
168 "w": 1.5
169 },
170 "\n\n|\n\\",
171 {
172 "a": 6,
173 "f": 3
174 },
175 "X",
176 {
177 "x": 14.5,
178 "a": 4
179 },
180 "/\n?",
181 {
182 "a": 4,
183 "w": 1.5
184 },
185 "~\n`"
186 ],
187 [
188 {
189 "y": -0.375,
190 "x": 3.5,
191 "a": 6
192 },
193 "E",
194 {
195 "x": 10.5
196 },
197 "T"
198 ],
199 [
200 {
201 "y": -0.875,
202 "x": 2.5
203 },
204 "O",
205 {
206 "x": 1,
207 "n": true
208 },
209 "I",
210 {
211 "x": 8.5,
212 "n": true
213 },
214 "R",
215 {
216 "x": 1
217 },
218 "N"
219 ],
220 [
221 {
222 "y": -0.875,
223 "x": 5.5
224 },
225 "U",
226 {
227 "x": 6.5
228 },
229 "D"
230 ],
231 [
232 {
233 "y": -0.875,
234 "fa": [
235 6
236 ],
237 "w": 1.5
238 },
239 "<i class='fa fa-arrows'></i>\n\nTab",
240 {
241 "f": 3
242 },
243 "A",
244 {
245 "x": 14.5,
246 "f": 3
247 },
248 "S",
249 {
250 "a": 4,
251 "fa": [
252 0,
253 0,
254 0,
255 0,
256 0,
257 0,
258 0,
259 6
260 ],
261 "w": 1.5
262 },
263 "+\n="
264 ],
265 [
266 {
267 "y": -0.625,
268 "x": 6.5,
269 "a": 7,
270 "f": 9,
271 "h": 1.5
272 },
273 "<i class='fa fa-columns'></i>",
274 {
275 "x": 4.5,
276 "h": 1.5
277 },
278 "<i class='fa fa-table'></i>"
279 ],
280 [
281 {
282 "y": -0.75,
283 "x": 3.5,
284 "a": 4,
285 "f": 3
286 },
287 "\"\n'",
288 {
289 "x": 10.5,
290 "a": 6,
291 "f": 3
292 },
293 "V"
294 ],
295 [
296 {
297 "y": -0.875,
298 "x": 2.5,
299 "a": 6
300 },
301 "Q",
302 {
303 "x": 1,
304 "a": 4
305 },
306 "<\n,",
307 {
308 "x": 8.5,
309 "a": 6
310 },
311 "K",
312 {
313 "x": 1
314 },
315 "Y"
316 ],
317 [
318 {
319 "y": -0.875,
320 "x": 5.5,
321 "a": 4
322 },
323 ">\n.",
324 {
325 "x": 6.5,
326 "a": 6
327 },
328 "B"
329 ],
330 [
331 {
332 "y": -0.875,
333 "f": 9,
334 "w": 1.5,
335 "g": true
336 },
337 "",
338 {
339 "a": 6,
340 "f": 3,
341 "g": false
342 },
343 "Z",
344 {
345 "x": 14.5
346 },
347 "J",
348 {
349 "f": 9,
350 "g": true,
351 "w": 1.5,
352 "a": 4
353 },
354 ""
355 ],
356 [
357 {
358 "y": -0.375,
359 "x": 3.5,
360 "g": true,
361 "a": 7,
362 "f": 3
363 },
364 "",
365 {
366 "x": 10.5
367 },
368 ""
369 ],
370 [
371 {
372 "y": -0.875,
373 "x": 2.5
374 },
375 "",
376 {
377 "x": 1,
378 "g": false,
379 "a": 5
380 },
381 ";\n:",
382 {
383 "x": 8.5
384 },
385 "_\n-",
386 {
387 "x": 1,
388 "g": true,
389 "a": 7
390 },
391 ""
392 ],
393 [
394 {
395 "y": -0.75,
396 "x": 0.5
397 },
398 "",
399 {},
400 "",
401 {
402 "x": 14.5
403 },
404 "",
405 {},
406 ""
407 ],
408 [
409 {
410 "r": 30,
411 "rx": 6.5,
412 "ry": 4.25,
413 "y": -1,
414 "x": 1,
415 "g": false
416 },
417 "Alt",
418 {
419 "a": 4,
420 "fa": [
421 0,
422 0,
423 0,
424 9
425 ]
426 },
427 "\n\n\n<i class='kb kb-logo-linux-debian fa-large'></i>"
428 ],
429 [
430 {
431 "a": 7,
432 "f": 9,
433 "h": 2
434 },
435 "<i class='kb kb-Unicode-BackSpace-DeleteLeft-Big'></i>",
436 {
437 "h": 2
438 },
439 "<i class='fa fa-angle-double-up'></i>",
440 {
441 "f": 3
442 },
443 "Ctrl"
444 ],
445 [
446 {
447 "x": 2
448 },
449 "ESC"
450 ],
451 [
452 {
453 "r": -30,
454 "rx": 13,
455 "y": -1,
456 "x": -3,
457 "f": 2
458 },
459 "MEDIA",
460 {},
461 "DEL"
462 ],
463 [
464 {
465 "x": -3
466 },
467 "HUN",
468 {
469 "f": 9,
470 "h": 2
471 },
472 "<i class='kb kb-Return-2'></i>",
473 {
474 "f": 3,
475 "h": 2
476 },
477 "SPC"
478 ],
479 [
480 {
481 "x": -3,
482 "f": 2
483 },
484 "LEAD"
485 ]
486]
diff --git a/layouts/community/ergodox/algernon/tools/heatmap-layout.Dvorak.json b/layouts/community/ergodox/algernon/tools/heatmap-layout.Dvorak.json
deleted file mode 100644
index 1e53281c5..000000000
--- a/layouts/community/ergodox/algernon/tools/heatmap-layout.Dvorak.json
+++ /dev/null
@@ -1,477 +0,0 @@
1[
2 {
3 "backcolor": "#ffffff",
4 "name": "ErgoDox - algernon's layout: Heatmap",
5 "author": "Gergely Nagy <kbd@gergo.csillger.hu>",
6 "notes": "See [here](https://github.com/algernon/ergodox-layout#readme) for the QMK keymap source.",
7 "switchMount": "cherry",
8 "switchBrand": "gateron",
9 "switchType": "KS-3-Tea",
10 "pcb": true,
11 "css": ".keyborder { -webkit-filter: blur(5px); filter: blur(5px); } .keytop { -webkit-filter: blur(10px); } .keylabels { border: 1px solid black; }"
12 },
13 [
14 {
15 "x": 3.5,
16 "fa": [
17 0,
18 0,
19 2
20 ]
21 },
22 "*\n5\nF5",
23 {
24 "x": 10.5,
25 "a": 4,
26 "fa": [
27 0,
28 0,
29 2
30 ]
31 },
32 "#\n4\nF4"
33 ],
34 [
35 {
36 "y": -0.875,
37 "x": 2.5
38 },
39 "@\n7\nF7",
40 {
41 "x": 1
42 },
43 "^\n3\nF3",
44 {
45 "x": 8.5
46 },
47 "!\n2\nF2",
48 {
49 "x": 1
50 },
51 "&\n6\nF6"
52 ],
53 [
54 {
55 "y": -0.875,
56 "x": 5.5
57 },
58 "$\n1\nF1",
59 {
60 "a": 7,
61 "f": 3
62 },
63 "F11",
64 {
65 "x": 4.5,
66 "f": 3
67 },
68 "Fx",
69 {
70 "a": 4,
71 "f": 3,
72 "fa": [
73 0,
74 0,
75 2
76 ]
77 },
78 "%\n0\nF10"
79 ],
80 [
81 {
82 "y": -0.875,
83 "f": 6,
84 "a": 6,
85 "w": 1.5
86 },
87 "<i class='fa fa-fast-backward'></i>\n\n<i class='fa fa-fast-forward'></i>",
88 {
89 "f": 3,
90 "a": 4,
91 "fa": [
92 0,
93 0,
94 2
95 ]
96
97 },
98 " \n9\nF9",
99 {
100 "x": 14.5
101 },
102 " \n8\nF8",
103 {
104 "a": 7,
105 "w": 1.5
106 },
107 "STENO"
108 ],
109 [
110 {
111 "y": -0.375,
112 "x": 3.5,
113 "a": 4
114 },
115 ">\n.",
116 {
117 "x": 10.5,
118 "a": 6
119 },
120 "C"
121 ],
122 [
123 {
124 "y": -0.875,
125 "x": 2.5,
126 "a": 4
127 },
128 "<\n,",
129 {
130 "x": 1,
131 "a": 6
132 },
133 "P",
134 {
135 "x": 8.5
136 },
137 "G",
138 {
139 "x": 1
140 },
141 "R"
142 ],
143 [
144 {
145 "y": -0.875,
146 "x": 5.5
147 },
148 "Y",
149 {
150 "a": 4,
151 "h": 1.5
152 },
153 "{\n(\n[",
154 {
155 "x": 4.5,
156 "h": 1.5
157 },
158 "}\n)\n]",
159 {
160 "a": 6
161 },
162 "F"
163 ],
164 [
165 {
166 "y": -0.875,
167 "f": 3,
168 "a": 4,
169 "w": 1.5
170 },
171 "\n\n~\n`",
172 {
173 "a": 4,
174 "f": 3
175 },
176 "\"\n'",
177 {
178 "x": 14.5,
179 "a": 6
180 },
181 "L",
182 {
183 "a": 4,
184 "w": 1.5
185 },
186 "|\n\\"
187 ],
188 [
189 {
190 "y": -0.375,
191 "x": 3.5,
192 "a": 6
193 },
194 "E",
195 {
196 "x": 10.5
197 },
198 "T"
199 ],
200 [
201 {
202 "y": -0.875,
203 "x": 2.5
204 },
205 "O",
206 {
207 "x": 1,
208 "n": true
209 },
210 "U",
211 {
212 "x": 8.5,
213 "n": true
214 },
215 "H",
216 {
217 "x": 1
218 },
219 "N"
220 ],
221 [
222 {
223 "y": -0.875,
224 "x": 5.5
225 },
226 "I",
227 {
228 "x": 6.5
229 },
230 "D"
231 ],
232 [
233 {
234 "y": -0.875,
235 "fa": [
236 6
237 ],
238 "w": 1.5
239 },
240 "<i class='fa fa-arrows'></i>\n\nTab",
241 {
242 "f": 3
243 },
244 "A",
245 {
246 "x": 14.5,
247 "f": 3
248 },
249 "S",
250 {
251 "a": 4,
252 "fa": [
253 0,
254 0,
255 0,
256 0,
257 0,
258 0,
259 0,
260 6
261 ],
262 "w": 1.5
263 },
264 "+\n="
265 ],
266 [
267 {
268 "y": -0.625,
269 "x": 6.5,
270 "a": 7,
271 "f": 9,
272 "h": 1.5
273 },
274 "<i class='fa fa-columns'></i>",
275 {
276 "x": 4.5,
277 "h": 1.5
278 },
279 "<i class='fa fa-table'></i>"
280 ],
281 [
282 {
283 "y": -0.75,
284 "x": 3.5,
285 "f": 3,
286 "a": 6
287 },
288 "J",
289 {
290 "x": 10.5
291 },
292 "W"
293 ],
294 [
295 {
296 "y": -0.875,
297 "x": 2.5
298 },
299 "Q",
300 {
301 "x": 1
302 },
303 "K",
304 {
305 "x": 8.5
306 },
307 "M",
308 {
309 "x": 1
310 },
311 "V"
312 ],
313 [
314 {
315 "y": -0.875,
316 "x": 5.5
317 },
318 "X",
319 {
320 "x": 6.5
321 },
322 "B"
323 ],
324 [
325 {
326 "y": -0.875,
327 "f": 9,
328 "w": 1.5
329 },
330 "\n\n<i class='kb kb-Multimedia-Play-Pause'></i>",
331 {
332 "a": 4,
333 "f": 3
334 },
335 "?\n/",
336 {
337 "x": 14.5,
338 "a": 6
339 },
340 "Z",
341 {
342 "f": 9,
343 "w": 1.5
344 },
345 "<i class='kb kb-Multimedia-Stop'></i>"
346 ],
347 [
348 {
349 "y": -0.375,
350 "x": 3.5,
351 "g": true,
352 "a": 7,
353 "f": 3
354 },
355 "",
356 {
357 "x": 10.5
358 },
359 ""
360 ],
361 [
362 {
363 "y": -0.875,
364 "x": 2.5
365 },
366 "",
367 {
368 "x": 1,
369 "g": false,
370 "a": 5
371 },
372 ";\n:",
373 {
374 "x": 8.5
375 },
376 "_\n-",
377 {
378 "x": 1,
379 "g": true,
380 "a": 7
381 },
382 ""
383 ],
384 [
385 {
386 "y": -0.75,
387 "x": 0.5
388 },
389 "",
390 {},
391 "",
392 {
393 "x": 14.5
394 },
395 "",
396 {},
397 ""
398 ],
399 [
400 {
401 "r": 30,
402 "rx": 6.5,
403 "ry": 4.25,
404 "y": -1,
405 "x": 1,
406 "g": false
407 },
408 "Alt",
409 {
410 "a": 4,
411 "fa": [
412 0,
413 0,
414 0,
415 9
416 ]
417 },
418 "\n\n\n<i class='kb kb-logo-linux-debian fa-large'></i>"
419 ],
420 [
421 {
422 "a": 7,
423 "f": 9,
424 "h": 2
425 },
426 "<i class='kb kb-Unicode-BackSpace-DeleteLeft-Big'></i>",
427 {
428 "h": 2
429 },
430 "<i class='fa fa-angle-double-up'></i>",
431 {
432 "f": 3
433 },
434 "Ctrl"
435 ],
436 [
437 {
438 "x": 2
439 },
440 "ESC"
441 ],
442 [
443 {
444 "r": -30,
445 "rx": 13,
446 "y": -1,
447 "x": -3,
448 "f": 2
449 },
450 "MEDIA",
451 {},
452 "DEL"
453 ],
454 [
455 {
456 "x": -3
457 },
458 "LEAD",
459 {
460 "f": 9,
461 "h": 2
462 },
463 "<i class='kb kb-Return-2'></i>",
464 {
465 "f": 3,
466 "h": 2
467 },
468 "SPC"
469 ],
470 [
471 {
472 "x": -3,
473 "f": 2
474 },
475 "HUN"
476 ]
477]
diff --git a/layouts/community/ergodox/algernon/tools/hid-commands b/layouts/community/ergodox/algernon/tools/hid-commands
deleted file mode 100755
index 86bff2978..000000000
--- a/layouts/community/ergodox/algernon/tools/hid-commands
+++ /dev/null
@@ -1,113 +0,0 @@
1#!/bin/bash
2set -e
3
4LAST_APPSEL_START=0
5
6cmd_wm () {
7 WIN="$(xdotool getactivewindow)"
8 wmctrl -i -r ${WIN} -b remove,maximized_vert,maximized_horz
9 xdotool windowsize ${WIN} 100% 100%
10 wmctrl -i -r ${WIN} -b add,maximized_vert,maximized_horz
11}
12
13cmd_appsel_helper () {
14 rofi -show window
15}
16
17_cmd_appsel () {
18 wmctrl -x -a $1 || true
19 xdotool key Escape
20}
21
22cmd_appsel_music () {
23 wmctrl -x -a rhythmbox || wmctrl -x -a spotify || \
24 wmctrl -x -a banshee || wmctrl -x -a kodi || \
25 wmctrl -x -a plex || true
26 xdotool key Escape
27}
28
29cmd_appsel_slack () {
30 wmctrl -x -a slack || wmctrl -x -a Mstdn || true
31 xdotool key Escape
32}
33
34cmd_appsel_emacs () {
35 _cmd_appsel emacs
36}
37
38cmd_appsel_term () {
39 _cmd_appsel gnome-terminal
40}
41
42cmd_appsel_chrome () {
43 wmctrl -x -a chrom || wmctrl -x -a Chrome || true
44 xdotool key Escape
45}
46
47cmd_appsel_start () {
48 if [ ! -z "${DISABLE_APPSEL_START}" ]; then
49 return
50 fi
51
52 APPSEL_START=$(date +%s)
53 if [ $APPSEL_START -lt $(expr $LAST_APPSEL_START + 10) ]; then
54 return
55 fi
56 LAST_APPSEL_START=$APPSEL_START
57 notify-send -t 1000 "Please select an application!" -c device -u low \
58 -i /usr/share/icons/Adwaita/24x24/devices/video-display.png
59}
60
61cmd_appsel_social () {
62 # Save the current window
63 a=$(xdotool getactivewindow)
64 # Raise & Focus Mstdn & Tweetdeck
65 wmctrl -x -a trunk.mad-scientist.club.Google-chrome || true; wmctrl -x -a tweetdeck || true
66 # Focus the previously active window
67 xdotool windowfocus $a || true; xdotool windowactivate $a || true
68
69 xdotool key Escape
70}
71
72cmd_appsel_social2 () {
73 # Save the current window
74 a=$(xdotool getactivewindow)
75 # Raise & Focus Viber & Signal
76 wmctrl -x -a Viber || true; wmctrl -a Signal || true
77 # Focus the previously active window
78 xdotool windowfocus $a || true; xdotool windowactivate $a || true
79
80 xdotool key Escape
81}
82
83cmd_appsel_pwmgr () {
84 _cmd_appsel keepass
85}
86
87cmd_reflash () {
88 teensy_loader_cli -v -w ~/src/ext/qmk_firmware/algernon.hex --mcu atmega32u4 || true
89}
90
91cmd_help () {
92 cat <<EOF
93Use the source, Luke!
94EOF
95}
96
97while read l; do
98 case "$l" in
99 "CMD:"*)
100 ;;
101 *)
102 continue
103 ;;
104 esac
105
106 cmd="$(echo $l | cut -d: -f2-)"
107
108 echo "Got command: ${cmd}"
109
110 if type cmd_${cmd} >/dev/null 2>&1; then
111 cmd_${cmd}
112 fi
113done
diff --git a/layouts/community/ergodox/algernon/tools/log-to-heatmap.py b/layouts/community/ergodox/algernon/tools/log-to-heatmap.py
deleted file mode 100755
index 5f52d9932..000000000
--- a/layouts/community/ergodox/algernon/tools/log-to-heatmap.py
+++ /dev/null
@@ -1,342 +0,0 @@
1#! /usr/bin/env python3
2import json
3import os
4import sys
5import re
6import argparse
7import time
8
9from math import floor
10from os.path import dirname
11from blessings import Terminal
12
13class Heatmap(object):
14 coords = [
15 [
16 # Row 0
17 [ 4, 0], [ 4, 2], [ 2, 0], [ 1, 0], [ 2, 2], [ 3, 0], [ 3, 2],
18 [ 3, 4], [ 3, 6], [ 2, 4], [ 1, 2], [ 2, 6], [ 4, 4], [ 4, 6],
19 ],
20 [
21 # Row 1
22 [ 8, 0], [ 8, 2], [ 6, 0], [ 5, 0], [ 6, 2], [ 7, 0], [ 7, 2],
23 [ 7, 4], [ 7, 6], [ 6, 4], [ 5, 2], [ 6, 6], [ 8, 4], [ 8, 6],
24 ],
25 [
26 # Row 2
27 [12, 0], [12, 2], [10, 0], [ 9, 0], [10, 2], [11, 0], [ ],
28 [ ], [11, 2], [10, 4], [ 9, 2], [10, 6], [12, 4], [12, 6],
29 ],
30 [
31 # Row 3
32 [17, 0], [17, 2], [15, 0], [14, 0], [15, 2], [16, 0], [13, 0],
33 [13, 2], [16, 2], [15, 4], [14, 2], [15, 6], [17, 4], [17, 6],
34 ],
35 [
36 # Row 4
37 [20, 0], [20, 2], [19, 0], [18, 0], [19, 2], [], [], [], [],
38 [19, 4], [18, 2], [19, 6], [20, 4], [20, 6], [], [], [], []
39 ],
40 [
41 # Row 5
42 [ ], [23, 0], [22, 2], [22, 0], [22, 4], [21, 0], [21, 2],
43 [24, 0], [24, 2], [25, 0], [25, 4], [25, 2], [26, 0], [ ],
44 ],
45 ]
46
47 def set_attr_at(self, block, n, attr, fn, val):
48 blk = self.heatmap[block][n]
49 if attr in blk:
50 blk[attr] = fn(blk[attr], val)
51 else:
52 blk[attr] = fn(None, val)
53
54 def coord(self, col, row):
55 return self.coords[row][col]
56
57 @staticmethod
58 def set_attr(orig, new):
59 return new
60
61 def set_bg(self, coords, color):
62 (block, n) = coords
63 self.set_attr_at(block, n, "c", self.set_attr, color)
64 #self.set_attr_at(block, n, "g", self.set_attr, False)
65
66 def set_tap_info(self, coords, count, cap):
67 (block, n) = coords
68 def _set_tap_info(o, _count, _cap):
69 ns = 4 - o.count ("\n")
70 return o + "\n" * ns + "%.02f%%" % (float(_count) / float(_cap) * 100)
71
72 if not cap:
73 cap = 1
74 self.heatmap[block][n + 1] = _set_tap_info (self.heatmap[block][n + 1], count, cap)
75
76 @staticmethod
77 def heatmap_color (v):
78 colors = [ [0.3, 0.3, 1], [0.3, 1, 0.3], [1, 1, 0.3], [1, 0.3, 0.3]]
79 fb = 0
80 if v <= 0:
81 idx1, idx2 = 0, 0
82 elif v >= 1:
83 idx1, idx2 = len(colors) - 1, len(colors) - 1
84 else:
85 val = v * (len(colors) - 1)
86 idx1 = int(floor(val))
87 idx2 = idx1 + 1
88 fb = val - float(idx1)
89
90 r = (colors[idx2][0] - colors[idx1][0]) * fb + colors[idx1][0]
91 g = (colors[idx2][1] - colors[idx1][1]) * fb + colors[idx1][1]
92 b = (colors[idx2][2] - colors[idx1][2]) * fb + colors[idx1][2]
93
94 r, g, b = [x * 255 for x in (r, g, b)]
95 return "#%02x%02x%02x" % (int(r), int(g), int(b))
96
97 def __init__(self, layout):
98 self.log = {}
99 self.total = 0
100 self.max_cnt = 0
101 self.layout = layout
102
103 def update_log(self, coords):
104 (c, r) = coords
105 if not (c, r) in self.log:
106 self.log[(c, r)] = 0
107 self.log[(c, r)] = self.log[(c, r)] + 1
108 self.total = self.total + 1
109 if self.max_cnt < self.log[(c, r)]:
110 self.max_cnt = self.log[(c, r)]
111
112 def get_heatmap(self):
113 with open("%s/heatmap-layout.%s.json" % (dirname(sys.argv[0]), self.layout), "r") as f:
114 self.heatmap = json.load (f)
115
116 ## Reset colors
117 for row in self.coords:
118 for coord in row:
119 if coord != []:
120 self.set_bg (coord, "#d9dae0")
121
122 for (c, r) in self.log:
123 coords = self.coord(c, r)
124 cap = self.max_cnt
125 if cap == 0:
126 cap = 1
127 v = float(self.log[(c, r)]) / cap
128 self.set_bg (coords, self.heatmap_color (v))
129 self.set_tap_info (coords, self.log[(c, r)], self.total)
130 return self.heatmap
131
132 def get_stats(self):
133 usage = [
134 # left hand
135 [0, 0, 0, 0, 0],
136 # right hand
137 [0, 0, 0, 0, 0]
138 ]
139 finger_map = [0, 0, 1, 2, 3, 3, 3, 1, 1, 1, 2, 3, 4, 4]
140 for (c, r) in self.log:
141 if r == 5: # thumb cluster
142 if c <= 6: # left side
143 usage[0][4] = usage[0][4] + self.log[(c, r)]
144 else:
145 usage[1][0] = usage[1][0] + self.log[(c, r)]
146 elif r == 4 and (c == 4 or c == 9): # bottom row thumb keys
147 if c <= 6: # left side
148 usage[0][4] = usage[0][4] + self.log[(c, r)]
149 else:
150 usage[1][0] = usage[1][0] + self.log[(c, r)]
151 else:
152 fc = c
153 hand = 0
154 if fc >= 7:
155 hand = 1
156 fm = finger_map[fc]
157 usage[hand][fm] = usage[hand][fm] + self.log[(c, r)]
158 hand_usage = [0, 0]
159 for f in usage[0]:
160 hand_usage[0] = hand_usage[0] + f
161 for f in usage[1]:
162 hand_usage[1] = hand_usage[1] + f
163
164 total = self.total
165 if total == 0:
166 total = 1
167 stats = {
168 "total-keys": total,
169 "hands": {
170 "left": {
171 "usage": round(float(hand_usage[0]) / total * 100, 2),
172 "fingers": {
173 "pinky": 0,
174 "ring": 0,
175 "middle": 0,
176 "index": 0,
177 "thumb": 0,
178 }
179 },
180 "right": {
181 "usage": round(float(hand_usage[1]) / total * 100, 2),
182 "fingers": {
183 "thumb": 0,
184 "index": 0,
185 "middle": 0,
186 "ring": 0,
187 "pinky": 0,
188 }
189 },
190 }
191 }
192
193 hmap = ['left', 'right']
194 fmap = ['pinky', 'ring', 'middle', 'index', 'thumb',
195 'thumb', 'index', 'middle', 'ring', 'pinky']
196 for hand_idx in range(len(usage)):
197 hand = usage[hand_idx]
198 for finger_idx in range(len(hand)):
199 stats['hands'][hmap[hand_idx]]['fingers'][fmap[finger_idx + hand_idx * 5]] = round(float(hand[finger_idx]) / total * 100, 2)
200 return stats
201
202def dump_all(out_dir, heatmaps):
203 stats = {}
204 t = Terminal()
205 t.clear()
206 sys.stdout.write("\x1b[2J\x1b[H")
207
208 print ('{t.underline}{outdir}{t.normal}\n'.format(t=t, outdir=out_dir))
209
210 keys = list(heatmaps.keys())
211 keys.sort()
212
213 for layer in keys:
214 if len(heatmaps[layer].log) == 0:
215 continue
216
217 with open ("%s/%s.json" % (out_dir, layer), "w") as f:
218 json.dump(heatmaps[layer].get_heatmap(), f)
219 stats[layer] = heatmaps[layer].get_stats()
220
221 left = stats[layer]['hands']['left']
222 right = stats[layer]['hands']['right']
223
224 print ('{t.bold}{layer}{t.normal} ({total:,} taps):'.format(t=t, layer=layer,
225 total=int(stats[layer]['total-keys'] / 2)))
226 print (('{t.underline} | ' + \
227 'left ({l[usage]:6.2f}%) | ' + \
228 'right ({r[usage]:6.2f}%) |{t.normal}').format(t=t, l=left, r=right))
229 print ((' {t.bright_magenta}pinky{t.white} | {left[pinky]:6.2f}% | {right[pinky]:6.2f}% |\n' + \
230 ' {t.bright_cyan}ring{t.white} | {left[ring]:6.2f}% | {right[ring]:6.2f}% |\n' + \
231 ' {t.bright_blue}middle{t.white} | {left[middle]:6.2f}% | {right[middle]:6.2f}% |\n' + \
232 ' {t.bright_green}index{t.white} | {left[index]:6.2f}% | {right[index]:6.2f}% |\n' + \
233 ' {t.bright_red}thumb{t.white} | {left[thumb]:6.2f}% | {right[thumb]:6.2f}% |\n' + \
234 '').format(left=left['fingers'], right=right['fingers'], t=t))
235
236def process_line(line, heatmaps, opts, stamped_log = None):
237 m = re.search ('KL: col=(\d+), row=(\d+), pressed=(\d+), layer=(.*)', line)
238 if not m:
239 return False
240 if stamped_log is not None:
241 if line.startswith("KL:"):
242 print ("%10.10f %s" % (time.time(), line),
243 file = stamped_log, end = '')
244 else:
245 print (line,
246 file = stamped_log, end = '')
247 stamped_log.flush()
248
249 (c, r, l) = (int(m.group (2)), int(m.group (1)), m.group (4))
250 if (c, r) not in opts.allowed_keys:
251 return False
252
253 heatmaps[l].update_log ((c, r))
254
255 return True
256
257def setup_allowed_keys(opts):
258 if len(opts.only_key):
259 incmap={}
260 for v in opts.only_key:
261 m = re.search ('(\d+),(\d+)', v)
262 if not m:
263 continue
264 (c, r) = (int(m.group(1)), int(m.group(2)))
265 incmap[(c, r)] = True
266 else:
267 incmap={}
268 for r in range(0, 6):
269 for c in range(0, 14):
270 incmap[(c, r)] = True
271
272 for v in opts.ignore_key:
273 m = re.search ('(\d+),(\d+)', v)
274 if not m:
275 continue
276 (c, r) = (int(m.group(1)), int(m.group(2)))
277 del(incmap[(c, r)])
278
279 return incmap
280
281def main(opts):
282 heatmaps = {"Dvorak": Heatmap("Dvorak"),
283 "ADORE": Heatmap("ADORE")
284 }
285 cnt = 0
286 out_dir = opts.outdir
287
288 if not os.path.exists(out_dir):
289 os.makedirs(out_dir)
290
291 opts.allowed_keys = setup_allowed_keys(opts)
292
293 if not opts.one_shot:
294
295 try:
296 with open("%s/stamped-log" % out_dir, "r") as f:
297 while True:
298 line = f.readline()
299 if not line:
300 break
301 if not process_line(line, heatmaps, opts):
302 continue
303 except Exception:
304 pass
305
306 stamped_log = open ("%s/stamped-log" % (out_dir), "a+")
307 else:
308 stamped_log = None
309
310 while True:
311 line = sys.stdin.readline()
312 if not line:
313 break
314 if not process_line(line, heatmaps, opts, stamped_log):
315 continue
316
317 cnt = cnt + 1
318
319 if opts.dump_interval != -1 and cnt >= opts.dump_interval and not opts.one_shot:
320 cnt = 0
321 dump_all(out_dir, heatmaps)
322
323 dump_all (out_dir, heatmaps)
324
325if __name__ == "__main__":
326 parser = argparse.ArgumentParser (description = "keylog to heatmap processor")
327 parser.add_argument ('outdir', action = 'store',
328 help = 'Output directory')
329 parser.add_argument ('--dump-interval', dest = 'dump_interval', action = 'store', type = int,
330 default = 100, help = 'Dump stats and heatmap at every Nth event, -1 for dumping at EOF only')
331 parser.add_argument ('--ignore-key', dest = 'ignore_key', action = 'append', type = str,
332 default = [], help = 'Ignore the key at position (x, y)')
333 parser.add_argument ('--only-key', dest = 'only_key', action = 'append', type = str,
334 default = [], help = 'Only include key at position (x, y)')
335 parser.add_argument ('--one-shot', dest = 'one_shot', action = 'store_true',
336 help = 'Do not load previous data, and do not update it, either.')
337 args = parser.parse_args()
338 if len(args.ignore_key) and len(args.only_key):
339 print ("--ignore-key and --only-key are mutually exclusive, please only use one of them!",
340 file = sys.stderr)
341 sys.exit(1)
342 main(args)
diff --git a/layouts/community/ergodox/algernon/tools/text-to-log.py b/layouts/community/ergodox/algernon/tools/text-to-log.py
deleted file mode 100755
index ba60a2e28..000000000
--- a/layouts/community/ergodox/algernon/tools/text-to-log.py
+++ /dev/null
@@ -1,106 +0,0 @@
1#!/usr/bin/env python3
2
3import sys
4
5charmap = {
6 '9': [[1, 0]],
7 '7': [[2, 0]], '@': [[2, 5], [2, 0]],
8 '5': [[3, 0]], '*': [[2, 5], [3, 0]],
9 '3': [[4, 0]], '^': [[2, 5], [4, 0]],
10 '1': [[5, 0]], '$': [[2, 5], [5, 0]],
11 '0': [[8, 0]], '%': [[2, 5], [8, 0]],
12 '2': [[9, 0]], '!': [[2, 5], [9, 0]],
13 '4': [[10, 0]], '#': [[2, 5], [10, 0]],
14 '6': [[11, 0]], '&': [[2, 5], [11, 0]],
15 '8': [[12, 0]],
16
17 '\\': [[0, 1]], '|': [[2, 5], [0, 1]],
18 'x': [[1, 1]], 'X': [[2, 5], [1, 1]],
19 'w': [[2, 1]], 'W': [[2, 5], [2, 1]],
20 'c': [[3, 1]], 'C': [[2, 5], [3, 1]],
21 'h': [[4, 1]], 'H': [[2, 5], [4, 1]],
22 'f': [[5, 1]], 'F': [[2, 5], [5, 1]],
23 '[': [[6, 1]], '{': [[2, 5], [6, 1]], '(': [[6, 1], [6, 1]],
24 ']': [[7, 1]], '}': [[2, 5], [7, 1]], ')': [[7, 1], [7, 1]],
25 'm': [[8, 1]], 'M': [[2, 5], [8, 1]],
26 'g': [[9, 1]], 'G': [[2, 5], [9, 1]],
27 'l': [[10, 1]], 'L': [[2, 5], [10, 1]],
28 'p': [[11, 1]], 'P': [[2, 5], [11, 1]],
29 '/': [[12, 1]], '?': [[2, 5], [12, 1]],
30 '`': [[13, 1]], '~': [[2, 5], [13, 1]],
31
32 '\t': [[0, 2]],
33 'a': [[1, 2]], 'A': [[2, 5], [1, 2]],
34 'o': [[2, 2]], 'O': [[2, 5], [2, 2]],
35 'e': [[3, 2]], 'E': [[2, 5], [3, 2]],
36 'i': [[4, 2]], 'I': [[2, 5], [4, 2]],
37 'u': [[5, 2]], 'U': [[2, 5], [5, 2]],
38 'd': [[8, 2]], 'D': [[2, 5], [8, 2]],
39 'r': [[9, 2]], 'R': [[2, 5], [9, 2]],
40 't': [[10, 2]], 'T': [[2, 5], [10, 2]],
41 'n': [[11, 2]], 'N': [[2, 5], [11, 2]],
42 's': [[12, 2]], 'S': [[2, 5], [12, 2]],
43 '=': [[13, 2]], '+': [[2, 5], [13, 2]],
44
45 'z': [[1, 3]], 'Z': [[2, 5], [1, 3]],
46 'q': [[2, 3]], 'Q': [[2, 5], [2, 3]],
47 '\'': [[3, 3]], '"': [[2, 5], [3, 3]],
48 ',': [[4, 3]], '<': [[2, 5], [4, 3]],
49 '.': [[5, 3]], '>': [[2, 5], [5, 3]],
50 'b': [[8, 3]], 'B': [[2, 5], [8, 3]],
51 'k': [[9, 3]], 'K': [[2, 5], [9, 3]],
52 'v': [[10, 3]], 'V': [[2, 5], [10, 3]],
53 'y': [[11, 3]], 'Y': [[2, 5], [11, 3]],
54 'j': [[12, 3]], 'J': [[2, 5], [12, 3]],
55
56 ':': [[4, 4]], ';': [[4, 4], [4, 4]],
57 '-': [[9, 4]], '_': [[2, 5], [9, 4]],
58
59 ' ': [[10, 5]],
60 '\n': [[11, 5]],
61
62 ## Layered things
63 # Hungarian
64 'á': [[9, 5], [1, 2]], 'Á': [[2, 5], [9, 5], [1, 2]],
65 'ó': [[9, 5], [2, 2]], 'Ó': [[2, 5], [9, 5], [2, 2]],
66 'ő': [[9, 5], [2, 1]], 'Ő': [[2, 5], [9, 5], [2, 1]],
67 'ö': [[9, 5], [2, 3]], 'Ö': [[2, 5], [9, 5], [2, 3]],
68 'é': [[9, 5], [3, 2]], 'É': [[2, 5], [9, 5], [3, 2]],
69 'ú': [[9, 5], [4, 2]], 'Ú': [[2, 5], [9, 5], [4, 2]],
70 'ű': [[9, 5], [4, 1]], 'Ű': [[2, 5], [9, 5], [4, 1]],
71 'ü': [[9, 5], [4, 3]], 'Ü': [[2, 5], [9, 5], [4, 3]],
72 'í': [[9, 5], [5, 2]], 'Í': [[2, 5], [9, 5], [5, 2]],
73}
74
75def lookup_char(layer, ch):
76 if ch in charmap:
77 return charmap[ch]
78 return None
79
80def process_char(layer, ch, out=sys.stdout):
81 keys = lookup_char(layer, ch)
82 if not keys:
83 print ("Unknown char: %s" % ch, file=sys.stderr)
84 else:
85 for (c, r) in keys:
86 print ("KL: col=%d, row=%d, pressed=1, layer=%s" % (r, c, layer), file=out)
87 print ("KL: col=%d, row=%d, pressed=0, layer=%s" % (r, c, layer), file=out)
88
89def process_file(fn, layer, out=sys.stdout):
90 with open(fn, "r") as f:
91 ch = f.read(1)
92 while ch:
93 process_char(layer, ch, out)
94 ch = f.read(1)
95
96if sys.argv[1] == '-':
97 out='/dev/stdin'
98else:
99 out=sys.argv[1]
100
101if len(sys.argv) >= 2:
102 layer = 'ADORE'
103else:
104 layer = sys.argv[2]
105
106process_file(out, layer = layer)