feat: caps lock key configuration

Esc on press, ctrl on hold.
This commit is contained in:
Oliver Davies 2023-06-01 00:36:19 +01:00
parent 342ea10202
commit bf3d81656d
3 changed files with 23 additions and 9 deletions

View file

@ -236,7 +236,6 @@ default_border pixel 3
input * {
xkb_layout "gb"
# xkb_options "caps:swapescape"
}
input type:touchpad {
@ -250,7 +249,6 @@ smart_gaps on
gaps inner 10
exec configure-gtk
exec configue-keyboard
bindsym --locked XF86AudioLowerVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- -l 1.2
bindsym --locked XF86AudioRaiseVolume exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ -l 1.2

View file

@ -5,12 +5,6 @@
dotDir = ".config/zsh";
initExtra = ''
# Make Caps Lock behave like Ctrl.
setxkbmap -option ctrl:nocaps
# Make short-pressed Ctrl behave like Escape.
xcape -e 'Control_L=Escape'
# Plugins
source "''${ZPLUG_REPOS}/robbyrussell/oh-my-zsh/plugins/git/git.plugin.zsh"
source "''${ZPLUG_REPOS}/robbyrussell/oh-my-zsh/plugins/vi-mode/vi-mode.plugin.zsh"

View file

@ -2,7 +2,7 @@
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
{ config, lib, pkgs, ... }:
let
nixpkgs = import ../../shared/nixpkgs.nix { };
@ -175,5 +175,27 @@ in {
[ (nerdfonts.override { fonts = [ "FiraCode" "JetBrainsMono" ]; }) ];
zramSwap.enable = true;
# Make Caps lock work as an Escape key on press and Ctrl on hold.
services.interception-tools =
let
dfkConfig = pkgs.writeText "dual-function-keys.yaml" ''
MAPPINGS:
- KEY: KEY_CAPSLOCK
TAP: KEY_ESC
HOLD: KEY_LEFTCTRL
'';
in
{
enable = true;
plugins = lib.mkForce [ pkgs.interception-tools-plugins.dual-function-keys ];
udevmonConfig = ''
- JOB: "${pkgs.interception-tools}/bin/intercept -g $DEVNODE | ${pkgs.interception-tools-plugins.dual-function-keys}/bin/dual-function-keys -c ${dfkConfig} | ${pkgs.interception-tools}/bin/uinput -d $DEVNODE"
DEVICE:
NAME: "AT Translated Set 2 keyboard"
EVENTS:
EV_KEY: [[KEY_CAPSLOCK, KEY_ESC, KEY_LEFTCTRL]]
'';
};
}