1
Fork 0
satellite/hosts/nixos/common/optional/services/kanata.nix

156 lines
5.6 KiB
Nix
Raw Permalink Normal View History

{ ... }:
2024-02-24 01:53:32 +01:00
let
stickTap = action: "tap-hold-press 0 200 (one-shot-press-pcancel 1000 (${action})) (${action})";
mkConfig = { blueTrigger, redTrigger, chordDelay }: ''
;; {{{ Source layout
(defsrc
grv 1 2 3 4 5 6 7 8 9 0 - = bspc
tab q w e r t y u i o p [ ] \
caps a s d f g h j k l ; ' ret
lsft z x c v b n m , . / rsft
lctl lmet ${redTrigger} spc ${blueTrigger}
)
;; }}}
;; {{{ Layer & utility aliases
(defalias
red (layer-while-held red)
blue (layer-while-held blue)
2024-02-24 01:53:32 +01:00
purple (layer-while-held purple)
2024-02-24 01:53:32 +01:00
em (unicode )
)
;; }}}
2024-07-26 20:18:26 +02:00
(defchordsv2-experimental
2024-02-24 01:53:32 +01:00
;; {{{ Left modifiers
2024-07-26 20:18:26 +02:00
(a s d f) (multi lctl lalt lsft) ${toString chordDelay} all-released ()
(a s d ) (multi lalt lsft) ${toString chordDelay} all-released ()
( s d f) (multi lctl lsft) ${toString chordDelay} all-released ()
(a s ) lalt ${toString chordDelay} all-released ()
( s d ) lsft ${toString chordDelay} all-released ()
( s f) lctl ${toString chordDelay} all-released ()
2024-02-24 01:53:32 +01:00
;; }}}
;; {{{ Right modifiers
2024-07-26 20:18:26 +02:00
(j k l ;) (multi rctl ralt rsft) ${toString chordDelay} all-released ()
(j k l ) (multi rctl rsft) ${toString chordDelay} all-released ()
( k l ;) (multi ralt rsft) ${toString chordDelay} all-released ()
(j l ) rctl ${toString chordDelay} all-released ()
( k l ) rsft ${toString chordDelay} all-released ()
( l ;) ralt ${toString chordDelay} all-released ()
2024-02-24 01:53:32 +01:00
;; }}}
;; {{{ Special keys
2024-07-26 20:18:26 +02:00
(d f) tab ${toString chordDelay} all-released ()
(e f) ret ${toString chordDelay} all-released ()
(q w) esc ${toString chordDelay} all-released ()
2024-07-26 20:18:26 +02:00
(g h) bspc ${toString chordDelay} all-released ()
(n l) rmet ${toString chordDelay} all-released ()
2024-07-26 20:18:26 +02:00
(j k) f10 ${toString chordDelay} all-released ()
(c p) f11 ${toString chordDelay} all-released ()
(j i) f12 ${toString chordDelay} all-released ()
2024-02-24 01:53:32 +01:00
;; }}}
;; {{{ Wm keybinds
2024-07-26 20:18:26 +02:00
(n l k) M-p ${toString chordDelay} all-released ()
(n l q) M-1 ${toString chordDelay} all-released ()
(n l w) M-2 ${toString chordDelay} all-released ()
(n l e) M-3 ${toString chordDelay} all-released ()
(n l r) M-4 ${toString chordDelay} all-released ()
(n l t) M-5 ${toString chordDelay} all-released ()
(n l a) M-6 ${toString chordDelay} all-released ()
(n l s) M-7 ${toString chordDelay} all-released ()
(n l d) M-8 ${toString chordDelay} all-released ()
(n l f) M-9 ${toString chordDelay} all-released ()
(n l g) M-0 ${toString chordDelay} all-released ()
2024-02-24 01:53:32 +01:00
;; }}}
)
;; {{{ Qwerty
(deflayer qwerty
XX XX XX XX XX XX XX XX XX XX XX XX XX XX
2024-07-26 20:18:26 +02:00
XX q w e r t y u i o p XX XX XX
XX a s d f g h j k l ; XX XX
lsft z x c v b n m , . ' XX
2024-02-24 01:53:32 +01:00
XX lmet @red spc @blue
)
;; }}}
;; {{{ Transparent template
(deflayer template
_ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _
)
;; }}}
2024-02-24 01:53:32 +01:00
;; {{{ Blue
(deflayer blue
_ _ _ _ _ _ _ _ _ _ _ _ _ _
_ S-= S-2 S-3 S-4 S-5 S-- S-7 S-8 grv S-grv _ _ _
2024-02-24 01:53:32 +01:00
_ S-, S-[ [ S-9 S-/ S-\ - / = S-; _ _
_ S-. S-] ] S-0 S-1 @em S-6 _ _ S-' _
_ _ @purple \ _
2024-02-24 01:53:32 +01:00
)
;; }}}
2024-02-24 01:53:32 +01:00
;; {{{ Red
(deflayer red
_ _ _ _ _ _ _ _ _ _ _ _ _ _
_ 1 2 3 4 5 home pgdn pgup end del _ _ _
_ 6 7 8 9 0 left down up rght _ _ _
_ _ _ _ _ _ _ _ _ _ _ _
2024-02-24 01:53:32 +01:00
_ _ _ _ @purple
)
;; }}}
;; {{{ Purple
(defalias
;; Press once to active caps lock for a word (revert after being idle
;; for 2s), or twice for real caps lock.
cps (tap-dance 200 ((caps-word 2000) caps))
2024-02-24 01:53:32 +01:00
udo (arbitrary-code 131) ;; undo
cpy (arbitrary-code 133) ;; copy
pst (arbitrary-code 135) ;; paste
cut (arbitrary-code 137) ;; cut
)
2024-02-24 01:53:32 +01:00
(deflayer purple
_ _ _ _ _ _ _ _ _ _ _ _ _ _
_ f1 f2 f3 f4 f5 @cps @cpy next volu brup _ _ _
_ f6 f7 f8 f9 f10 @udo @pst pp vold brdn _ _
_ f11 f12 _ _ _ _ @cut prev mute _ _
2024-02-24 01:53:32 +01:00
_ _ _ _ _
)
;; }}}
'';
2024-07-26 20:18:26 +02:00
extraDefCfg = ''
concurrent-tap-hold true ;; Required by chords
'';
in
{
services.kanata = {
enable = true;
keyboards.tethysLaptop = {
2024-07-26 20:18:26 +02:00
inherit extraDefCfg;
devices = [ "/dev/input/by-path/platform-i8042-serio-0-event-kbd" ];
config = mkConfig {
redTrigger = "lalt";
blueTrigger = "ralt";
chordDelay = 25;
};
};
keyboards.keychronK6 = {
2024-07-26 20:18:26 +02:00
inherit extraDefCfg;
devices = [ "/dev/input/by-id/usb-Keychron_Keychron_K6-event-kbd" ];
config = mkConfig {
redTrigger = "lalt";
blueTrigger = "rctl";
chordDelay = 30;
};
};
};
}