Skip to content

Commit a94b887

Browse files
authored
Merge pull request #64 from willpuckett/master
add karabiner.ts and goku configs
2 parents 797c33f + ca02824 commit a94b887

7 files changed

Lines changed: 404 additions & 1 deletion

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
#*
22
.#*
33
.ipynb_checkpoints/*-checkpoint.ipynb
4+
.DS_Store
5+
deno.lock
6+
.clj-kondo
7+
.lsp

install/mac/karabiner/README.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,67 @@
1+
# Engram Config for Karabiner
2+
3+
Engram layouts for Karabiner.
4+
5+
6+
```ts
7+
[{ 1| 2= 3~ 4+ 5< 6> 7^ 8& 9% 0* ]}
8+
bB yY oO uU '( ") lL dD wW vV zZ #$ @`
9+
cCiIeEaA ,; .: ⇧hHtTsSnN qQ
10+
gG xX jJ kK -_ ?! rR mM fF pP /\
11+
⌫ ␣ ⏎
12+
```
13+
14+
115
# Using Karabiner with Engram
216
3-
To use Engram on MacOS, simply
17+
To use the vanilla Engram layout on MacOS, simply
418
519
1. Install Karabiner `brew install karabiner-elements` (you'll have to grant necessary permissions in `System Settings`, detailed on the [Karabiner website](https://karabiner-elements.pqrs.org)).
620
2. Click this link to open the Engram layout [directly in Karabiner](https://smote.io/install_engram.html)
721
822
Or you can view the JSON [here](https://raw.githubusercontent.com/binarybottle/engram/master/install/mac/karabiner/engram.json) (you'll need to place the json file in `~/.config/karabiner/assets/complex_modifications/` and maybe restart Karabiner if you want to customize/ install manually).
23+
24+
25+
## Using a karabiner.json Generator
26+
27+
This directory also includes [Karabiner.ts](https://github.com/evan-liu/karabiner.ts) config, as well as a [Goku](https://github.com/yqrashawn/GokuRakuJoudo) config.
28+
29+
Home Row Mods are working better in the Karabiner.ts config than the Goku one. (They're configured as simlayers in the Karabiner.ts version.) Karabiner.ts also 🏃🏻‍♂️s 53 times faster--73.6ms vs. 3.947s.
30+
31+
The command keys are set to work more like they do on a mech ergo board.
32+
33+
Currently, Home Row Mods work only one at a time, but hoping to get that sorted shortly. 🤓
34+
35+
Karabiner still has some shortcomings. It seems like no matter how it's configured, typing rhythm isn't as natural with Karabiner as it is with [timeless Home Row Mods](https://github.com/urob/zmk-config#timeless-homerow-mods) in zmk using below config.
36+
37+
```dtsi
38+
hrml: home_row_mod_left {
39+
compatible = "zmk,behavior-hold-tap";
40+
label = "HOME_ROW_MOD_LEFT";
41+
#binding-cells = <2>;
42+
flavor = "balanced";
43+
tapping-term-ms = <HM_TAPPING_TERM>;
44+
hold-trigger-key-positions = < KEYS_R THUMBS >;
45+
hold-trigger-on-release;
46+
bindings = <&kp>, <&kp>;
47+
};
48+
```
49+
50+
51+
## Installing
52+
53+
### Karabiner.ts
54+
55+
1. Clone this repo.
56+
2. cd to this subdirectory `cd engram/install/mac/karabiner`.
57+
3. Create a profile in Karabiner called 'karabiner.ts'.
58+
4. Run `deno task build` in the repo directory.
59+
60+
### Goku
61+
62+
1. Clone this repository.
63+
2. cd to this subdirectory `cd engram/install/mac/karabiner`.
64+
3. Create a profile in Karabiner called 'goku'.
65+
4. Install Goku `brew install yqrashawn/goku/goku`.
66+
5. From the repo directory, copy the config file to your `.config` directory `cp karabiner.edn ~/.config`.
67+
6. Run Goku `goku`

install/mac/karabiner/deno.jsonc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"tasks": {
3+
"build": "deno run -A index.ts"
4+
},
5+
"importMap": "import_map.json",
6+
"fmt": {
7+
"semiColons": false,
8+
"singleQuote": true
9+
}
10+
}

install/mac/karabiner/engram.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { FromKeyParam, ModifierParam, ToKeyParam } from 'karabinerts'
2+
3+
interface IEngram {
4+
from: FromKeyParam
5+
fromMod?: ModifierParam
6+
to: ToKeyParam
7+
toMod?: ModifierParam
8+
}
9+
10+
const thumbs: IEngram[] = [
11+
{ from: '⇥', to: '⇥' },
12+
{ from: '␣', to: '␣' },
13+
{ from: '<⌘', to: '⌫' },
14+
{ from: '>⌘', to: '⏎' },
15+
]
16+
17+
const left: IEngram[] = [
18+
// Number Row
19+
{ from: '`', to: '[' },
20+
{ from: 1, fromMod: '⇧', to: '\\', toMod: '⇧' },
21+
{ from: 2, fromMod: '⇧', to: '=' },
22+
{ from: 3, fromMod: '⇧', to: '`', toMod: '⇧' },
23+
{ from: 4, fromMod: '⇧', to: '=', toMod: '⇧' },
24+
{ from: 5, fromMod: '⇧', to: ',', toMod: '⇧' },
25+
// Center Column/Punctuation
26+
{ from: 't', fromMod: '⇧', to: '9', toMod: '⇧' },
27+
{ from: 't', to: 'quote' },
28+
{ from: 'g', fromMod: '⇧', to: ';' },
29+
{ from: 'g', to: 'comma' },
30+
{ from: 'b', to: '-' },
31+
// Letters
32+
{ from: 'q', to: 'b' },
33+
{ from: 'w', to: 'y' },
34+
{ from: 'e', to: 'o' },
35+
{ from: 'r', to: 'u' },
36+
{ from: 'a', to: 'c' },
37+
{ from: 's', to: 'i' },
38+
{ from: 'd', to: 'e' },
39+
{ from: 'f', to: 'a' },
40+
{ from: 'z', to: 'g' },
41+
{ from: 'x', to: 'x' },
42+
{ from: 'c', to: 'j' },
43+
{ from: 'v', to: 'k' },
44+
]
45+
46+
const right: IEngram[] = [
47+
// Number Row
48+
{ from: 6, fromMod: '⇧', to: '.', toMod: '⇧' },
49+
{ from: 7, fromMod: '⇧', to: '6', toMod: '⇧' },
50+
{ from: 8, fromMod: '⇧', to: '7', toMod: '⇧' },
51+
{ from: 9, fromMod: '⇧', to: '5', toMod: '⇧' },
52+
{ from: 0, fromMod: '⇧', to: '8', toMod: '⇧' },
53+
{ from: '-', to: ']' },
54+
{ from: '=', fromMod: '⇧', to: '\\' },
55+
{ from: '=', to: '/' },
56+
// Center Column/Punctuation
57+
{ from: 'y', fromMod: '⇧', to: '0', toMod: '⇧' },
58+
{ from: 'y', to: '\'', toMod: '⇧' },
59+
{ from: 'h', fromMod: '⇧', to: ';', toMod: '⇧' },
60+
{ from: 'h', to: '.' },
61+
{ from: 'n', fromMod: '⇧', to: '1', toMod: '⇧' },
62+
{ from: 'n', to: '/', toMod: '⇧' },
63+
{ from: ']', fromMod: '⇧', to: '4', toMod: '⇧' },
64+
{ from: ']', to: '3', toMod: '⇧' },
65+
{ from: '\\', fromMod: '⇧', to: '`' },
66+
{ from: '\\', to: '2', toMod: '⇧' },
67+
{ from: '>⇧', fromMod: '⇧', to: '\\' },
68+
{ from: '>⇧', to: '/' },
69+
// Letters
70+
{ from: 'u', to: 'l' },
71+
{ from: 'i', to: 'd' },
72+
{ from: 'o', to: 'w' },
73+
{ from: 'p', to: 'v' },
74+
{ from: '[', to: 'z' },
75+
{ from: 'j', to: 'h' },
76+
{ from: 'k', to: 't' },
77+
{ from: 'l', to: 's' },
78+
{ from: ';', to: 'n' },
79+
{ from: '\'', to: 'q' },
80+
{ from: 'm', to: 'r' },
81+
{ from: ',', to: 'm' },
82+
{ from: '.', to: 'f' },
83+
{ from: '/', to: 'p' },
84+
]
85+
86+
export const engram = [
87+
...left,
88+
...right,
89+
]
90+
91+
export const engram_left = [...left, ...thumbs]
92+
export const engram_right = [...right, ...thumbs]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"imports": {
3+
"karabinerts": "https://deno.land/x/karabinerts/deno.ts"
4+
}
5+
}

install/mac/karabiner/index.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import {
2+
layer,
3+
map,
4+
rule,
5+
simlayer,
6+
// toKey,
7+
withMapper,
8+
withModifier,
9+
writeToProfile,
10+
} from 'karabinerts'
11+
import { engram, engram_left, engram_right } from './engram.ts'
12+
13+
// writeToProfile("--dry-run", [
14+
writeToProfile('karabiner.ts', [
15+
layer('⇪', 'nav').manipulators([
16+
withModifier('optionalAny')([
17+
map('u').to('↖︎'),
18+
map('i').to('⇟'),
19+
map('o').to('⇞'),
20+
map('p').to('↘︎'),
21+
map('j').to('←'),
22+
map('k').to('↓'),
23+
map('l').to('↑'),
24+
map(';').to('→'),
25+
map('m').to('z', '<⌘'),
26+
map(',').to('x', '<⌘'),
27+
map('.').to('c', '<⌘'),
28+
map('/').to('v', '<⌘'),
29+
]),
30+
]),
31+
simlayer('f', '<⇧').manipulators([
32+
// Reminder to experiment with .toDelayedAction() method
33+
// map('<⌘').toIfAlone('⌫').to('<⌘').toDelayedAction(toKey('m'), toKey('t')),
34+
// withMapper(engram_right)((k) => map(k.from, k.fromMod).to(k.to, "⌘⇧").condition(ifVar("<⌘", 1))),
35+
// withMapper(engram_right)((k) => map(k.from, k.fromMod).to(k.to, "⇧⌥").condition(ifVar("<⌥", 1))),
36+
// withMapper(engram_right)((k) => map(k.from, k.fromMod).to(k.to, "⌃⇧").condition(ifVar("<⌃", 1))),
37+
withMapper(engram_right)((k) => map(k.from, k.fromMod).to(k.to, '⇧')),
38+
]),
39+
simlayer('j', '>⇧').manipulators([
40+
// withMapper(engram_left)((k) => map(k.from, k.fromMod).to(k.to, "⌘⇧").condition(ifVar(">⌘", 1))),
41+
// withMapper(engram_left)((k) => map(k.from, k.fromMod).to(k.to, "⇧⌥").condition(ifVar(">⌥", 1))),
42+
// withMapper(engram_left)((k) => map(k.from, k.fromMod).to(k.to, "⌃⇧").condition(ifVar(">⌃", 1))),
43+
withMapper(engram_left)((k) => map(k.from, k.fromMod).to(k.to, '⇧')),
44+
]),
45+
simlayer('d', '<⌘').manipulators([
46+
// withMapper(engram_right)((k) => map(k.from, k.fromMod).to(k.to, "⌘⌥").condition(ifVar("<⌥", 1))),
47+
withMapper(engram_right)((k) => map(k.from, k.fromMod).to(k.to, '⌘')),
48+
]),
49+
simlayer('k', '>⌘').manipulators([
50+
// withMapper(engram_left)((k) => map(k.from, k.fromMod).to(k.to, "⌘⌥").condition(ifVar(">⌥", 1))),
51+
withMapper(engram_left)((k) => map(k.from, k.fromMod).to(k.to, '⌘')),
52+
]),
53+
simlayer('s', '<⌥').manipulators([
54+
withMapper(engram_right)((k) => map(k.from, k.fromMod).to(k.to, '⌥')),
55+
]),
56+
simlayer('l', '>⌥').manipulators([
57+
withMapper(engram_left)((k) => map(k.from, k.fromMod).to(k.to, '⌥')),
58+
]),
59+
simlayer('a', '<⌃').manipulators([
60+
withMapper(engram_right)((k) => map(k.from, k.fromMod).to(k.to, '⌃')),
61+
]),
62+
simlayer(';', '>⌃').manipulators([
63+
withMapper(engram_left)((k) => map(k.from, k.fromMod).to(k.to, '⌃')),
64+
]),
65+
66+
rule('short pinkies').manipulators([
67+
withModifier('optionalAny')([
68+
map('<⌘').toIfAlone('⌫').to('<⌘'),
69+
map('>⌘').toIfAlone('⏎').to('<⌘'),
70+
map('=').to('⌫'),
71+
map('>⇧', '<⇧').to('\\'),
72+
map('>⇧').to('/'),
73+
]),
74+
]),
75+
rule('engram').manipulators([
76+
withModifier('optionalAny')([
77+
withMapper(engram)((k) => map(k.from, k.fromMod).to(k.to, k.toMod)),
78+
]),
79+
]),
80+
], {
81+
'simlayer.threshold_milliseconds': 300,
82+
'basic.to_delayed_action_delay_milliseconds': 251,
83+
'basic.to_if_alone_timeout_milliseconds': 250,
84+
'basic.to_if_held_down_threshold_milliseconds': 251,
85+
})

0 commit comments

Comments
 (0)