refactor(nix/darwin): Swap ESC<->CapsLock with Kanata
This commit is contained in:
parent
b48174745d
commit
da9dcf8bdc
7 changed files with 99 additions and 14 deletions
22
include/kanata.kbd
Normal file
22
include/kanata.kbd
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
(defcfg
|
||||||
|
process-unmapped-keys yes
|
||||||
|
)
|
||||||
|
|
||||||
|
(defsrc
|
||||||
|
esc f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12
|
||||||
|
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 102d z x c v b n m , . / rsft
|
||||||
|
lctl lmet lalt spc ralt f13 rctl
|
||||||
|
)
|
||||||
|
|
||||||
|
;; Swap CapsLock with ESC
|
||||||
|
(deflayer base
|
||||||
|
caps f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12
|
||||||
|
grv 1 2 3 4 5 6 7 8 9 0 - = bspc
|
||||||
|
tab q w e r t y u i o p [ ]
|
||||||
|
esc a s d f g h j k l ; ' \ ret
|
||||||
|
lsft 102d z x c v b n m , . / rsft
|
||||||
|
lctl lmet lalt spc ralt f13 rctl
|
||||||
|
)
|
25
nix/modules/darwin/kanata.nix
Normal file
25
nix/modules/darwin/kanata.nix
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{ user }:
|
||||||
|
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
launchd.user.agents.kanata = {
|
||||||
|
command = "/usr/bin/sudo ${pkgs.kanata}/bin/kanata -c ${../../../include/kanata.kbd} -n";
|
||||||
|
serviceConfig = {
|
||||||
|
UserName = user;
|
||||||
|
RunAtLoad = true;
|
||||||
|
KeepAlive = {
|
||||||
|
SuccessfulExit = false;
|
||||||
|
Crashed = true;
|
||||||
|
};
|
||||||
|
StandardErrorPath = "/Users/${user}/.logs/kanata.err.log";
|
||||||
|
StandardOutPath = "/Users/${user}/.logs/kanata.out.log";
|
||||||
|
ProcessType = "Interactive";
|
||||||
|
Nice = -30;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
security.sudo.extraConfig = ''
|
||||||
|
${user} ALL=(ALL) NOPASSWD: ${pkgs.kanata}/bin/kanata
|
||||||
|
'';
|
||||||
|
}
|
29
nix/overlays/darwin/kanata.nix
Normal file
29
nix/overlays/darwin/kanata.nix
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# Because building from source is broken due to `sw_vers` usage
|
||||||
|
#
|
||||||
|
# REF: https://github.com/NixOS/nixpkgs/pull/306546#issuecomment-2284484876
|
||||||
|
# REF: https://github.com/jtroo/kanata/issues/1209
|
||||||
|
final: prev:
|
||||||
|
|
||||||
|
{
|
||||||
|
kanata = final.stdenv.mkDerivation rec {
|
||||||
|
name = "kanata";
|
||||||
|
version = "v1.7.0";
|
||||||
|
|
||||||
|
src = final.fetchurl {
|
||||||
|
url = "https://github.com/jtroo/kanata/releases/download/${version}/kanata_macos_" +
|
||||||
|
(if final.stdenv.hostPlatform.isAarch64 then "arm64" else "x86_64");
|
||||||
|
sha256 =
|
||||||
|
if final.stdenv.hostPlatform.isAarch64 then
|
||||||
|
"83ad80fbaf8c7b0ec0e17052a02ca0b3057cbbeaf8a023a61541f1514a936b43"
|
||||||
|
else
|
||||||
|
"e3f0d99e512a84c5cae1f63e71c07ecdbff66dc89b053aba0abb4f9dee0cadc0";
|
||||||
|
};
|
||||||
|
|
||||||
|
phases = ["installPhase" "patchPhase"];
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp $src $out/bin/kanata
|
||||||
|
chmod +x $out/bin/kanata
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
|
@ -58,6 +58,8 @@ in {
|
||||||
|
|
||||||
pkgs.lf
|
pkgs.lf
|
||||||
pkgs.yazi # lf replacement, need further testing
|
pkgs.yazi # lf replacement, need further testing
|
||||||
|
|
||||||
|
pkgs.kanata
|
||||||
];
|
];
|
||||||
environment.extraSetup = ''
|
environment.extraSetup = ''
|
||||||
ln -sv ${pkgs.path} $out/nixpkgs
|
ln -sv ${pkgs.path} $out/nixpkgs
|
||||||
|
|
|
@ -4,6 +4,10 @@ let
|
||||||
mkCommon = import ../../lib/mkCommon.nix;
|
mkCommon = import ../../lib/mkCommon.nix;
|
||||||
mkSystem = import ../../lib/mkSystem.nix;
|
mkSystem = import ../../lib/mkSystem.nix;
|
||||||
mkBrew = import ../../overlays/darwin/brew.nix;
|
mkBrew = import ../../overlays/darwin/brew.nix;
|
||||||
|
|
||||||
|
kanataModules = [
|
||||||
|
(import ../../modules/darwin/kanata.nix { user = "ziro"; })
|
||||||
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Host list
|
# Host list
|
||||||
|
@ -24,6 +28,7 @@ in
|
||||||
inputs.firefox-darwin.overlay
|
inputs.firefox-darwin.overlay
|
||||||
(mkBrew { inherit system brew-api; nixpkgs = nixpkgs-stable; })
|
(mkBrew { inherit system brew-api; nixpkgs = nixpkgs-stable; })
|
||||||
(import ../../overlays/darwin/heliport.nix)
|
(import ../../overlays/darwin/heliport.nix)
|
||||||
|
(import ../../overlays/darwin/kanata.nix)
|
||||||
];
|
];
|
||||||
nur = nur;
|
nur = nur;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +42,7 @@ in
|
||||||
modules = [
|
modules = [
|
||||||
inputs.spicetify-nix.nixosModules.default # Also works on nix-darwin thanks to it being nixosConfiguration replacement for macOS
|
inputs.spicetify-nix.nixosModules.default # Also works on nix-darwin thanks to it being nixosConfiguration replacement for macOS
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
];
|
] ++ kanataModules;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Imaginary M1, just for reference
|
# Imaginary M1, just for reference
|
||||||
|
@ -52,6 +57,7 @@ in
|
||||||
extraOverlays = [
|
extraOverlays = [
|
||||||
inputs.firefox-darwin.overlay
|
inputs.firefox-darwin.overlay
|
||||||
(mkBrew { inherit system brew-api; nixpkgs = nixpkgs-stable; })
|
(mkBrew { inherit system brew-api; nixpkgs = nixpkgs-stable; })
|
||||||
|
(import ../../overlays/darwin/kanata.nix)
|
||||||
];
|
];
|
||||||
nur = nur;
|
nur = nur;
|
||||||
}
|
}
|
||||||
|
@ -65,6 +71,6 @@ in
|
||||||
modules = [
|
modules = [
|
||||||
inputs.spicetify-nix.nixosModules.default
|
inputs.spicetify-nix.nixosModules.default
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
];
|
] ++ kanataModules;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ in
|
||||||
extraOverlays = [
|
extraOverlays = [
|
||||||
inputs.firefox-darwin.overlay
|
inputs.firefox-darwin.overlay
|
||||||
(mkBrew { inherit system; inherit (inputs) brew-api; nixpkgs = nixpkgs-stable; })
|
(mkBrew { inherit system; inherit (inputs) brew-api; nixpkgs = nixpkgs-stable; })
|
||||||
|
(import ../overlays/darwin/kanata.nix)
|
||||||
];
|
];
|
||||||
nur = nur;
|
nur = nur;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,18 +15,18 @@
|
||||||
home.file."Library/Application Support/Floorp/native-messaging-hosts/passff.json".source = "${pkgs.passff-host}/share/passff-host/passff.json";
|
home.file."Library/Application Support/Floorp/native-messaging-hosts/passff.json".source = "${pkgs.passff-host}/share/passff-host/passff.json";
|
||||||
|
|
||||||
# Swap CapsLock with Esc for better vi-mode experience.
|
# Swap CapsLock with Esc for better vi-mode experience.
|
||||||
launchd.agents.CapsEscSwap = {
|
# launchd.agents.CapsEscSwap = {
|
||||||
enable = true;
|
# enable = true;
|
||||||
config = {
|
# config = {
|
||||||
ProgramArguments = [
|
# ProgramArguments = [
|
||||||
"/usr/bin/hidutil"
|
# "/usr/bin/hidutil"
|
||||||
"property"
|
# "property"
|
||||||
"--set"
|
# "--set"
|
||||||
''{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029},{"HIDKeyboardModifierMappingSrc":0x700000029,"HIDKeyboardModifierMappingDst":0x700000039}]}''
|
# ''{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029},{"HIDKeyboardModifierMappingSrc":0x700000029,"HIDKeyboardModifierMappingDst":0x700000039}]}''
|
||||||
];
|
# ];
|
||||||
RunAtLoad = true;
|
# RunAtLoad = true;
|
||||||
};
|
# };
|
||||||
};
|
# };
|
||||||
|
|
||||||
home.sessionVariables.MOZ_LEGACY_PROFILES = 1;
|
home.sessionVariables.MOZ_LEGACY_PROFILES = 1;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue