Skip to content

Commit

Permalink
Trial kanata and homerow mods
Browse files Browse the repository at this point in the history
  • Loading branch information
joinemm committed Nov 2, 2024
1 parent fe91689 commit e3f7d7f
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hosts/athens/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
workstation
])
(with self.nixosModules; [
keyd
laptop
kanata
])
(with inputs.nixos-hardware.nixosModules; [
lenovo-thinkpad-x1-11th-gen
Expand Down
1 change: 1 addition & 0 deletions modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let
})
[
./home
./kanata
./x11.nix
./keyd.nix
./work.nix
Expand Down
29 changes: 29 additions & 0 deletions modules/kanata/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ pkgs, user, ... }:
{
# https://github.com/jtroo/kanata/wiki/Avoid-using-sudo-on-Linux

users.users.${user.name}.extraGroups = [
"uinput"
"input"
];

boot.kernelModules = [ "uinput" ];

environment.systemPackages = [ pkgs.kanata ];

services.udev.extraRules = ''
KERNEL=="uinput", MODE="0660", GROUP="uinput", OPTIONS+="static_node=uinput"
'';

systemd.user.services.kanata = {
path = [
pkgs.xorg.xset
];
serviceConfig = {
ExecStart = "${pkgs.kanata}/bin/kanata -c ${./keymap.kbd}";
Environment = [
"DISPLAY=:0"
];
};
};
}
58 changes: 58 additions & 0 deletions modules/kanata/keymap.kbd
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
(defcfg
process-unmapped-keys yes
linux-x11-repeat-delay-rate 250,30
linux-dev /dev/input/by-path/platform-i8042-serio-0-event-kbd
)
(defsrc
a s d f h j k l ;
)
(defvar
;; Note: consider using different time values for your different fingers.
;; For example, your pinkies might be slower to release keys and index
;; fingers faster.
tap-time 200
hold-time 400

left-hand-keys (
q w e r t
a s d f g
z x c v b
)
right-hand-keys (
y u i o p
h j k l ;
n m , . /
)
)
(deflayer base
@a @s @d @f h @j @k @l @;
)

(deflayer nomods
a s d f h j k l ;
)

(deflayer arrows
_ _ _ _ left down up rght _
)

(deffakekeys
to-base (layer-switch base)
)
(defalias
tap (multi
(layer-switch nomods)
(on-idle-fakekey to-base tap 20)
)

fn (layer-toggle arrows)
a (tap-hold-release-keys $tap-time $hold-time (multi a @tap) lsft $left-hand-keys)
s (tap-hold-release-keys $tap-time $hold-time (multi s @tap) lctl $left-hand-keys)
d (tap-hold-release-keys $tap-time $hold-time (multi d @tap) lalt $left-hand-keys)
f (tap-hold-release-keys $tap-time $hold-time (multi f @tap) lmet $left-hand-keys)
j (tap-hold-release-keys $tap-time $hold-time (multi j @tap) rmet $right-hand-keys)
k (tap-hold-release-keys $tap-time $hold-time (multi k @tap) ralt $right-hand-keys)
l (tap-hold-release-keys $tap-time $hold-time (multi l @tap) rctl $right-hand-keys)
; (tap-hold-release-keys $tap-time $hold-time (multi ; @tap) rsft $right-hand-keys)
)

0 comments on commit e3f7d7f

Please sign in to comment.