complete-computing-environment/custom-keyboard-layout.org

2.0 KiB

My Custom Keyboard Layout

It seems silly to me that such "valuable" keyboard real-estate on the default QWERTY is left to <>; I rebind them instead to !? and shift things around to fill the gaps:

  • Shift + comma produces an exclamation point
  • Shift + period produces a question mark
  • Shift + slash produces a backslash
  • Shift + 1 produces a less-than mark
  • Shift + backslash produces a greater-than mark

On my custom keyboards, these are put in reasonable places, hitting Shift + NUMBER is not something I am looking to do, as I have a dedicated symbol layer. This isn't universal, however. By default, Shift + Backslash produces a pipe character, which is also in my Keyboardio Atreus's symbol layer.

{ pkgs, ... }:

let
  punctFile = pkgs.writeText "punctuations.xkb" ''
    default partial alphanumeric_keys modifier_keys
    xkb_symbols "rr_punctuations" {
        include "pc+us(basic)+inet(evdev)"

        name[Group1]= "US ASCII, punctuation swap";

        key <AE01> {[      1,      less ]};
        key <BKSL> {[    bar,   greater ]};
        key <AB08> {[  comma,    exclam ]};
        key <AB09> {[ period,  question ]};
        key <AB10> {[  slash, backslash ]};
    };
  '';
in {
  # load shift-sign changes
  # services.xserver.displayManager.sessionCommands = "${pkgs.xorg.xkbcomp}/bin/xkbcomp ${compiledLayout} $DISPLAY";
  services.xserver.xkb = {
    model = "pc104";
    layout = "punctual";
    # xkbVariant = "";
    # options = "ctrl:nocaps";
    extraLayouts = {
      punctual = {
        description = "Shift ,. become !?";
        languages = [ "eng" ];
        symbolsFile = punctFile;
      };
    };
  };
  console.useXkbConfig = true;
}