{ config, lib, pkgs, ... }: let commonSettings = { main = { capslock = "layer(capslock)"; insert = "S-insert"; }; meta = { w = "macro(C-w)"; a = "macro(C-a)"; }; "capslock:C" = { }; }; in { options.custom = with lib; { keyd = { enable = mkEnableOption "Enable keyd"; }; }; config = lib.mkIf config.custom.keyd.enable { environment.systemPackages = with pkgs; [ keyd ]; users.groups.keyd = { }; services.keyd = { enable = true; keyboards = { default = { ids = [ "*" ]; settings = commonSettings; }; workstation = { ids = [ "0001:0001:70533846" # framework "3434:06a0:d7dfbeabt" # keychron q10 "046d:c339:9f276ca6" # Logitech Pro ]; settings = lib.mkMerge [ commonSettings { main = { leftalt = "layer(meta)"; leftmeta = "layer(alt)"; }; } ]; }; }; }; systemd.services.keyd.serviceConfig.CapabilityBoundingSet = [ "CAP_SETGID" ]; environment.etc."libinput/local-overrides.quirks".text = '' [Serial Keyboards] MatchUdevType=keyboard MatchName=keyd virtual keyboard AttrKeyboardIntegration=internal ''; }; }