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

3.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 symbol layer. And so hitting

I use xmodmap to make some changes to my keyboard layout. I'd like to use xkbmap instead but changing my map causes nixpkgs to compile xwayland and kwin and a bunch of other necessities, so I use xxmodmap for now. Specifically, I run systemctl --user start fixup-punctuation-xmodmap whenever my keyboards are changed.

keycode 10 = 1 less 
keycode 51 = bar greater 

keycode 60 = period question
keycode 59 = comma exclam
keycode 61 = slash backslash
{ pkgs, ... }:

{
  # load shift-sign changes
  services.xserver.displayManager.sessionCommands = "${pkgs.xorg.xmodmap}/bin/xmodmap ${../files/Xmodmap}";
  systemd.user.services.fixup-punctuation-xmodmap = {
    description = "Apply XModmap configuration";
    wantedBy = ["post-resume.target"];
    after = ["post-resume.target"];
    script = ''
      sleep 1
      ${pkgs.xorg.xmodmap}/bin/xmodmap ${../files/Xmodmap}
    '';
    serviceConfig.Type = "oneshot";
  };
  # this causes a bunch of kde shit to be compiled from source, ugh.
  # services.xserver.extraLayouts.punctuation = {
  #   description = "swap around punctuations";
  #   languages = [ "us" ];
  #   symbolsFile = pkgs.writeText "punctuations.symbols" ''
  #     xkb_symbols "punctuations" {
  #         name[Group1]= "US ASCII, punctuation swap";
  #         include "pc+inet(evdev)"
  #         include "us(basic)"
  #     
  #         key <AE01> { [      1,      less ] };
  #         key <BKSL> { [    bar,   greater ] };
  #         key <AB08> { [  comma,    exclam ] };
  #         key <AB09> { [ period,  question ] };
  #         key <AB10> { [  slash, backslash ] };
  #     };
  #     '';
  # };
  # services.xserver.layout = "punctuation";
  # services.xserver.xkbModel = "punctuation";

  # this doesn't work at all...
  # services.xserver.extraLayouts = {
    #   rrix = {
#     description = "US QWERTY but with some punctuation changes";
  #     languages = [ "en" ];
  #     symbolsFile = ../../../server-0.xkb;
  #   };
  # };

}