diff --git a/config/keymap_drawer.yaml b/config/keymap_drawer.yaml index 70e7adc..6547eef 100644 --- a/config/keymap_drawer.yaml +++ b/config/keymap_drawer.yaml @@ -327,16 +327,16 @@ parse_config: KP_MULTIPLY: '*' KP_EQUAL: '=' KP_DOT: '.' - KP_N1: 1 - KP_N2: 2 - KP_N3: 3 - KP_N4: 4 - KP_N5: 5 - KP_N6: 6 - KP_N7: 7 - KP_N8: 8 - KP_N9: 9 - KP_N0: 0 + KP_N1: '1' + KP_N2: '2' + KP_N3: '3' + KP_N4: '4' + KP_N5: '5' + KP_N6: '6' + KP_N7: '7' + KP_N8: '8' + KP_N9: '9' + KP_N0: '0' 'LC(LEFT)': $$mdi:chevron-double-left$$ 'LC(RIGHT)': $$mdi:chevron-double-right$$ diff --git a/drawer/default.nix b/drawer/default.nix new file mode 100644 index 0000000..8b6bec6 --- /dev/null +++ b/drawer/default.nix @@ -0,0 +1,115 @@ +{ + inputs, + lib, + ... +}: +with builtins; +with lib; { + perSystem = { + config, + pkgs, + system, + ... + }: let + inherit (inputs.poetry2nix.lib.mkPoetry2Nix {inherit pkgs;}) mkPoetryApplication; + + getKeymapFiles = dir: + mapAttrsToList (name: _: dir + "/${name}") (filterAttrs (name: type: hasSuffix ".keymap" name && type != "directory") (readDir dir)); + + # Nix can't import yaml, so use `yj` to convert to JSON 😢 + importYaml = file: let + jsonFile = pkgs.runCommandNoCC "converted-yaml.json" {} '' + ${getExe pkgs.yj} < "${file}" > "$out" + ''; + in + importJSON jsonFile; + + pkg = config.packages.keymap-drawer; + exe = getExe pkg; + + parsedPkg = config.packages.keymap-drawer-parsed; + + # List of parsed keyboard configs, complete with various metadata + parsedCfgs = mapAttrsToList (fname: type: + assert hasSuffix ".yaml" fname; + assert type != "directory"; rec { + file = parsedPkg + "/${fname}"; + name = removeSuffix ".yaml" fname; + data = importYaml file; + layers = attrNames data.layers; + }) (readDir parsedPkg); + + keymapFiles = getKeymapFiles ../config; + configFile = ../config/keymap_drawer.yaml; + in { + packages = { + keymap-drawer = mkPoetryApplication { + projectDir = inputs.keymap-drawer; + preferWheels = true; + meta = { + mainProgram = "keymap"; + homepage = "https://github.com/caksoylar/keymap-drawer"; + }; + }; + + keymap-drawer-parsed = pkgs.symlinkJoin { + name = "configs"; + paths = map (file: let + name = removeSuffix ".keymap" (baseNameOf file); + in + pkgs.runCommandNoCC "${name}-parsed" {} '' + echo "Parsing keymap for ${name}" + mkdir -p "$out" + + # Create a temp link because keymap-drawer uses the file's stem + # to guess the keyboard name... + # Using `file` directly won't work because it has a nar hash prefix. + # FIXME find workaround upstream + LINK="$out/${baseNameOf file}" + ln -s "${file}" "$LINK" + + ${exe} --config "${configFile}" \ + parse --zmk-keymap "$LINK" \ + > "$out/${name}.yaml" + + # Cleanup temp link + rm "$LINK" + '') + keymapFiles; + }; + + keymap-drawer-svgs = pkgs.symlinkJoin { + name = "keymap-drawer-svgs"; + paths = + concatMap ( + { + file, + name, + layers, + ... + }: + [ + (pkgs.runCommandNoCC "${name}-all" {} '' + echo "Drawing all layers for ${name}" + mkdir -p "$out" + ${exe} --config "${configFile}" \ + draw "${file}" \ + > "$out/${name}.svg" + '') + ] + ++ (map (layer: + pkgs.runCommandNoCC "${name}-${layer}" {} '' + echo "Drawing ${layer} layer for ${name}" + mkdir -p "$out" + ${exe} --config "${configFile}" \ + draw "${file}" \ + --select-layers "${layer}" \ + > "$out/${name}-${layer}.svg" + '') + layers) + ) + parsedCfgs; + }; + }; + }; +} diff --git a/flake.lock b/flake.lock index df605a3..5a0fc47 100644 --- a/flake.lock +++ b/flake.lock @@ -59,6 +59,24 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "glove80-zmk": { "flake": false, "locked": { @@ -75,6 +93,43 @@ "type": "github" } }, + "keymap-drawer": { + "flake": false, + "locked": { + "lastModified": 1711220101, + "narHash": "sha256-XY/52aNvwuIJCbCF8xkDUKI9LTntwbmhJFr6DS4Yb+0=", + "owner": "caksoylar", + "repo": "keymap-drawer", + "rev": "f63ccf49bae1df2f58d3f6bab8a0fc13faf6c981", + "type": "github" + }, + "original": { + "owner": "caksoylar", + "repo": "keymap-drawer", + "type": "github" + } + }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703863825, + "narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "5163432afc817cf8bd1f031418d1869e4c9d5547", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1711163522, @@ -91,12 +146,38 @@ "type": "github" } }, + "poetry2nix": { + "inputs": { + "flake-utils": "flake-utils_2", + "nix-github-actions": "nix-github-actions", + "nixpkgs": [ + "nixpkgs" + ], + "systems": "systems_3", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1708589824, + "narHash": "sha256-2GOiFTkvs5MtVF65sC78KNVxQSmsxtk0WmV1wJ9V2ck=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "3c92540611f42d3fb2d0d084a6c694cd6544b609", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, "root": { "inputs": { "devshell": "devshell", "flake-parts": "flake-parts", "glove80-zmk": "glove80-zmk", - "nixpkgs": "nixpkgs" + "keymap-drawer": "keymap-drawer", + "nixpkgs": "nixpkgs", + "poetry2nix": "poetry2nix" } }, "systems": { @@ -113,6 +194,56 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "id": "systems", + "type": "indirect" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1708335038, + "narHash": "sha256-ETLZNFBVCabo7lJrpjD6cAbnE11eDOjaQnznmg/6hAE=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "e504621290a1fd896631ddbc5e9c16f4366c9f65", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index e98b6b3..9adfcb8 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,14 @@ url = "github:moergo-sc/zmk"; flake = false; }; + keymap-drawer = { + url = "github:caksoylar/keymap-drawer"; + flake = false; + }; + poetry2nix = { + url = "github:nix-community/poetry2nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; @@ -19,6 +27,8 @@ self, nixpkgs, glove80-zmk, + keymap-drawer, + poetry2nix, flake-parts, devshell, } @ inputs: @@ -26,6 +36,7 @@ systems = nixpkgs.lib.systems.flakeExposed; imports = [ inputs.devshell.flakeModule + ./drawer ]; perSystem = { diff --git a/img/glove80.svg b/img/glove80.svg index d8637f6..bab1fba 100644 --- a/img/glove80.svg +++ b/img/glove80.svg @@ -1,4 +1,4 @@ - + /* start glyphs */ @@ -116,6 +116,9 @@ svg.keymap { /* default key styling */ rect.key { fill: #f6f8fa; +} + +rect.key, rect.combo { stroke: #c9cccf; stroke-width: 1; } @@ -300,8 +303,8 @@ text.hold { } } - -ColmakDH + +default @@ -521,30 +524,30 @@ text.hold { V - + - + Num/Nav - + Meta - + Alt - + Num/Nav - + @@ -593,31 +596,31 @@ text.hold { - + - + Esc -Symbols +symbols - + Ctrl - + Ctrl - + -Symbols +symbols - + @@ -640,21 +643,21 @@ text.hold { Qwerty - - - - + + + + - - - -_ + + + +_ - -Qwerty + +qwerty @@ -864,27 +867,27 @@ text.hold { B - + - + - + - + - + - + @@ -932,27 +935,27 @@ text.hold { - + - + - + - + - + - + @@ -978,8 +981,8 @@ text.hold { - -Symbols + +symbols @@ -1189,25 +1192,25 @@ text.hold { € - + - + - + - + - + - + @@ -1255,25 +1258,25 @@ text.hold { - + - + - + - + - + - + @@ -1299,8 +1302,8 @@ text.hold { - -Navigation + +navigation @@ -1526,29 +1529,29 @@ text.hold { / - + - + Num/Nav - + - + - + Num/Nav - + @@ -1596,27 +1599,27 @@ text.hold { . - + - + Esc - + - + - + - + @@ -1642,8 +1645,8 @@ text.hold { - -Gaming + +gaming @@ -1850,27 +1853,27 @@ text.hold { V - + T - + G - + B - + - + - + @@ -1916,27 +1919,27 @@ text.hold { - + - + Esc - + ` - + - + - + @@ -1962,8 +1965,8 @@ text.hold { - -Magic + +magic @@ -2158,26 +2161,26 @@ text.hold { - + 2 - + 3 - + - + - + - + @@ -2214,27 +2217,27 @@ text.hold { - + 0 - + 1 - + - + - + - + diff --git a/img/glove80.yaml b/img/glove80.yaml index 33fd4d5..4a4822e 100644 --- a/img/glove80.yaml +++ b/img/glove80.yaml @@ -1,6 +1,6 @@ layout: {qmk_keyboard: glove80} layers: - ColmakDH: + default: - F1 - F2 - F3 @@ -71,17 +71,17 @@ layers: - '' - '' - $$mdi:backspace$$ - - {t: Esc, h: Symbols} + - {t: Esc, h: symbols} - {t: '$$mdi:keyboard-tab-reverse$$', h: Ctrl} - {t: '$$mdi:keyboard-tab$$', h: Ctrl} - - {t: '$$mdi:keyboard-return$$', h: Symbols} + - {t: '$$mdi:keyboard-return$$', h: symbols} - $$mdi:keyboard-space$$ - '' - '' - '' - AltGr - {t: '$$mdi:keyboard-outline$$', h: Qwerty, type: info} - Qwerty: + qwerty: - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} @@ -162,7 +162,7 @@ layers: - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} - Symbols: + symbols: - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} @@ -243,7 +243,7 @@ layers: - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} - Navigation: + navigation: - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} @@ -324,7 +324,7 @@ layers: - $$mdi:skip-next$$ - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} - Gaming: + gaming: - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} @@ -405,7 +405,7 @@ layers: - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} - {t: '$$mdi:chevron-down$$', type: trans} - Magic: + magic: - {t: '$$mdi:bluetooth-off$$', h: Clear, type: info} - '' - '' @@ -489,7 +489,7 @@ layers: combos: - p: [52, 57] k: $$mdi:apple-keyboard-caps$$ - l: [ColmakDH] + l: [default] - p: [69, 74] k: _ - l: [ColmakDH] + l: [default] diff --git a/img/glove80_default.svg b/img/glove80_default.svg new file mode 100644 index 0000000..49f8c42 --- /dev/null +++ b/img/glove80_default.svg @@ -0,0 +1,659 @@ + +/* start glyphs */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* end glyphs */ + + +default + + + +F1 + + + +F2 + + + +F3 + + + +F4 + + + +F5 + + + +F6 + + + +F7 + + + +F8 + + + +F9 + + + +F10 + + + +F11 + + + +1 +! + + + +2 +" + + + +3 +£ + + + +4 +$ + + + +5 +% + + + +6 +^ + + + +7 +& + + + +8 +* + + + +9 +( + + + +0 +) + + + +F12 + + + + + + +Q + + + +W + + + +F + + + +P + + + +B + + + +J + + + +L + + + +U + + + +Y + + + +' +" + + + + + + +_ +\ + + + +A + + + +R + + + +S + + + +T + + + +G + + + +M + + + +N + + + +E + + + +I + + + +O + + + +- +/ + + + + + + +Z + + + +X + + + +C + + + +D + + + +V + + + + + + + + +Num/Nav + + + + +Meta + + + +Alt + + + + +Num/Nav + + + + + + + +K + + + +H + + + +, +; + + + +. +: + + + +? +! + + + + + + + +Gaming + + + + +Magic + + + + + + + + + + + + + + + + +Esc +symbols + + + + +Ctrl + + + + +Ctrl + + + + +symbols + + + + + + + + + + + + + + + + +AltGr + + + + +Qwerty + + + + + + + + + + + +_ + + + + diff --git a/img/glove80_gaming.svg b/img/glove80_gaming.svg new file mode 100644 index 0000000..a0b4ed6 --- /dev/null +++ b/img/glove80_gaming.svg @@ -0,0 +1,626 @@ + +/* start glyphs */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* end glyphs */ + + +gaming + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Q + + + +W + + + +E + + + +R + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +A + + + +S + + + +D + + + +F + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Ctrl + + + +Z + + + +X + + + +C + + + +V + + + +T + + + +G + + + +B + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Gaming + + + +Alt + + + + + + + + + + + + + + + + +Esc + + + +` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/img/glove80_magic.svg b/img/glove80_magic.svg new file mode 100644 index 0000000..c2deb2a --- /dev/null +++ b/img/glove80_magic.svg @@ -0,0 +1,598 @@ + +/* start glyphs */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* end glyphs */ + + +magic + + + + +Clear + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Clr All + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +RGBSPI + + + + + +RGBSAI + + + + + +RGBHUI + + + + + +RGBBRI + + + + + +RGBTOG + + + + + + + + + + + + + + + + + + + + + + +Boot + + + + +RGBSPD + + + + + +RGBSAD + + + + + +RGBHUD + + + + + +RGBBRD + + + + + +RGBEFF + + + + + + + + + + + + + + + + + + + +Boot + + + +Reset + + + + + + + + + + + + + + + + + + + +2 + + + + +3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Reset + + + + + + + + + + + + + + + + + + + +0 + + + + +1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/img/glove80_navigation.svg b/img/glove80_navigation.svg new file mode 100644 index 0000000..718d247 --- /dev/null +++ b/img/glove80_navigation.svg @@ -0,0 +1,649 @@ + +/* start glyphs */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* end glyphs */ + + +navigation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ++ + + + +7 +F7 + + + +8 +F8 + + + +9 +F9 + + + +* +F11 + + + + +PgUp + + + + + + + + + + + + + + + + + +PgDown + + + + + + + + + + + + +0 +F10 + + + +4 +F4 + + + +5 +F5 + + + +6 +F6 + + + += +F12 + + + +Home + + + + + + + + + + + + + + + +End + + + + + + + + + + + +- + + + +1 +F1 + + + +2 +F2 + + + +3 +F3 + + + +/ + + + + + + + + +Num/Nav + + + + + + + + + + + + +Num/Nav + + + + + + + + + + + + + + + + + + + + + + + +Print + + + + + + + + + + + +€ + + + +$ + + + +£ + + + +. + + + + + + + +Esc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/img/glove80_qwerty.svg b/img/glove80_qwerty.svg new file mode 100644 index 0000000..9181872 --- /dev/null +++ b/img/glove80_qwerty.svg @@ -0,0 +1,631 @@ + +/* start glyphs */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* end glyphs */ + + +qwerty + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Q + + + +W + + + +E + + + +R + + + +T + + + +Y + + + +U + + + +I + + + +O + + + +P + + + + + + + + + + + +A + + + +S + + + +D + + + +F + + + +G + + + +H + + + +J + + + +K + + + +L + + + +; + + + + + + + + + + + +Z + + + +X + + + +C + + + +V + + + +B + + + + + + + + + + + + + + + + + + + + + + + + + + + +N + + + +M + + + +, + + + +. + + + +/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/img/glove80_symbols.svg b/img/glove80_symbols.svg new file mode 100644 index 0000000..8b9d139 --- /dev/null +++ b/img/glove80_symbols.svg @@ -0,0 +1,627 @@ + +/* start glyphs */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* end glyphs */ + + +symbols + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +` + + + +< + + + +> + + + +" + + + +£ + + + +: + + + +% + + + +[ + + + +] + + + +^ + + + + + + + + + + + +~ + + + +- + + + ++ + + + += + + + +# + + + +? + + + +! + + + +( + + + +) + + + +& + + + +@ + + + + + + + +\ + + + +/ + + + +* + + + +' + + + +€ + + + + + + + + + + + + + + + + + + + + + + + + + +; + + + +$ + + + +{ + + + +} + + + +| + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +