2024-04-02 23:18:43 +02:00
|
|
|
{ pkgs, lib, ... }:
|
2023-06-22 17:13:46 +02:00
|
|
|
|
2024-04-02 23:18:43 +02:00
|
|
|
let
|
2024-04-03 00:01:13 +02:00
|
|
|
inherit (lib) getExe singleton;
|
2024-04-02 23:18:43 +02:00
|
|
|
inherit (builtins) toJSON;
|
|
|
|
inherit (pkgs) interception-tools;
|
|
|
|
inherit (pkgs.interception-tools-plugins) dual-function-keys;
|
|
|
|
|
|
|
|
configFile = "dual-function-keys.yaml";
|
|
|
|
in
|
2023-06-22 17:13:46 +02:00
|
|
|
{
|
2023-05-16 23:18:06 +02:00
|
|
|
services.interception-tools = {
|
|
|
|
enable = true;
|
2024-04-02 23:18:43 +02:00
|
|
|
plugins = [ dual-function-keys ];
|
2023-06-12 19:40:56 +02:00
|
|
|
|
2024-04-03 00:01:13 +02:00
|
|
|
udevmonConfig = toJSON (singleton {
|
|
|
|
JOB = /* bash */ ''
|
|
|
|
${interception-tools}/bin/intercept -g $DEVNODE |
|
|
|
|
${getExe dual-function-keys} -c /etc/${configFile} |
|
|
|
|
${interception-tools}/bin/uinput -d $DEVNODE
|
|
|
|
'';
|
2024-04-02 23:18:43 +02:00
|
|
|
|
2024-04-03 00:01:13 +02:00
|
|
|
DEVICE = {
|
|
|
|
EVENTS = {
|
|
|
|
EV_KEY = [ "KEY_CAPSLOCK" "KEY_ESC" ];
|
2024-04-02 22:31:23 +02:00
|
|
|
};
|
2024-04-03 00:01:13 +02:00
|
|
|
};
|
|
|
|
});
|
2023-05-16 23:18:06 +02:00
|
|
|
};
|
|
|
|
|
2024-04-02 23:18:43 +02:00
|
|
|
environment.etc.${configFile}.text = toJSON {
|
2024-04-02 22:31:23 +02:00
|
|
|
TIMING = [
|
|
|
|
{ TAP_MILLISEC = 1000; }
|
|
|
|
{ DOUBLE_TAP_MILLISEC = 0; }
|
|
|
|
{ SYNTHETIC_KEYS_PAUSE_MILLISEC = 0; }
|
|
|
|
];
|
|
|
|
|
|
|
|
MAPPINGS = [
|
|
|
|
{
|
|
|
|
KEY = "KEY_CAPSLOCK";
|
|
|
|
TAP = "KEY_ESC";
|
|
|
|
HOLD = "KEY_LEFTCTRL";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
KEY = "KEY_SYSRQ";
|
|
|
|
TAP = "KEY_SYSRQ";
|
|
|
|
HOLD = "KEY_RIGHTMETA";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
KEY = "KEY_LEFTMETA";
|
|
|
|
TAP = [ "KEY_LEFTMETA" "KEY_F1" ];
|
|
|
|
HOLD = "KEY_LEFTMETA";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
KEY = "KEY_RIGHTSHIFT";
|
|
|
|
TAP = [ "KEY_LEFTMETA" "KEY_F2" ];
|
|
|
|
HOLD = "KEY_RIGHTSHIFT";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
KEY = "KEY_RIGHTALT";
|
|
|
|
TAP = "KEY_GRAVE";
|
|
|
|
HOLD = "KEY_RIGHTALT";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2023-05-16 23:18:06 +02:00
|
|
|
}
|