Keyd: Difference between revisions

Graic (talk | contribs)
Fix systemctl command
Arnecc (talk | contribs)
No edit summary
Line 60: Line 60:


Note that for now, ids MUST be present in the file, so it means that layouts cannot be defined this way as reported in https://github.com/NixOS/nixpkgs/issues/284797. Yet, you can still use `environment.etc` to create them as usual.
Note that for now, ids MUST be present in the file, so it means that layouts cannot be defined this way as reported in https://github.com/NixOS/nixpkgs/issues/284797. Yet, you can still use `environment.etc` to create them as usual.
=== Disabling Copilot key ===
An increasing number of new laptops come with a useless Copilot key that you might want to disable or remap. Follow these steps to do so:
Start a shell with keyd available <code>nix-shell -p keyd</code> to monitor what the Copilot key does and see your keyboard id. From that shell, run <code>sudo keyd monitor</code> and press the Copilot key.
<syntaxhighlight>
AT Translated Set 2 keyboard 0001:0001:09b4e68d leftmeta down
AT Translated Set 2 keyboard 0001:0001:09b4e68d leftshift down
AT Translated Set 2 keyboard 0001:0001:09b4e68d f23 down
AT Translated Set 2 keyboard 0001:0001:09b4e68d f23 up
AT Translated Set 2 keyboard 0001:0001:09b4e68d leftshift up
AT Translated Set 2 keyboard 0001:0001:09b4e68d leftmeta up
</syntaxhighlight>
You may then edit your configuration accordingly:
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
services.keyd = {
      enable = true;
      keyboards = {
        default = {
          ## the id of your keyboard taken from the monitor command - specifying it here and not using a wildcard * might avoid the aforementioned libinput issue with palm rejection. 
          ids = [ "0001:0001:09b4e68d" ];
          settings = {
            main = {
              ## taking the key combination from the monitor command and remapping it to control key
              "leftshift+leftmeta+f23" = "layer(control)";
            };
          };
        };
      };
    };
</nowiki>}}


=== Dealing with layouts ===
=== Dealing with layouts ===


If you want to define a layout (like you custom qwerty), you can also do it directly in keyd, but keep in mind that keyd can manipulate keycodes (basically the position of the key on the keyboard that is named based on a qwerty layout by convention), but not keysyms (what actual symbol you will type), since keyd they basically recreates a fake keyboard that will be, later in the chain, processed by X11/ibus/… So if you want to use a layout, you need to be sure that the layout used by the user is set to US (e.g. in X11 via <code>setxkbmap us</code>). If you want to produce symbols not accessible by the US keyboard map (e.g. emoji etc), then keyd will basically create for you a XCompose file that you need to include (you may also need to enable Ibus for this), that is located in <code>"${keyd}/share/keyd/keyd.compose"</code>. See keyd documentation for more details.
If you want to define a layout (like you custom qwerty), you can also do it directly in keyd, but keep in mind that keyd can manipulate keycodes (basically the position of the key on the keyboard that is named based on a qwerty layout by convention), but not keysyms (what actual symbol you will type), since keyd they basically recreates a fake keyboard that will be, later in the chain, processed by X11/ibus/… So if you want to use a layout, you need to be sure that the layout used by the user is set to US (e.g. in X11 via <code>setxkbmap us</code>). If you want to produce symbols not accessible by the US keyboard map (e.g. emoji etc), then keyd will basically create for you a XCompose file that you need to include (you may also need to enable Ibus for this), that is located in <code>"${keyd}/share/keyd/keyd.compose"</code>. See keyd documentation for more details.