From 07e03b03efce865a214016a54a3b358ce34d61fa Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 22 Oct 2023 16:39:55 +0200 Subject: [PATCH] Add docs and layout auto-generation --- .../workflows/generate-layout-previews.yaml | 28 + README.md | 13 + flake.nix | 9 + keyboards/qmk/ferris-sweep/README.md | 10 + keyboards/qmk/ferris-sweep/lens.svg | 517 ++++++++++++++++++ layout-lens/README.md | 13 + layout-lens/default.nix | 4 +- layout-lens/package-lock.json | 5 +- layout-lens/package.json | 2 - layout-lens/scripts/generate-layouts.sh | 11 + 10 files changed, 604 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/generate-layout-previews.yaml create mode 100644 README.md create mode 100644 keyboards/qmk/ferris-sweep/README.md create mode 100644 keyboards/qmk/ferris-sweep/lens.svg create mode 100644 layout-lens/README.md create mode 100644 layout-lens/scripts/generate-layouts.sh diff --git a/.github/workflows/generate-layout-previews.yaml b/.github/workflows/generate-layout-previews.yaml new file mode 100644 index 0000000..a450afa --- /dev/null +++ b/.github/workflows/generate-layout-previews.yaml @@ -0,0 +1,28 @@ +name: Generate layout previews + +on: + push: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Install Nix + uses: cachix/install-nix-action@v22 + + - name: Generate Files + run: | + nix run .#generate-layout-previews + + - name: Commit and Push Changes + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add . + git diff --quiet --cached || git commit -m "Auto-generated layout previews [skip ci]" + git push diff --git a/README.md b/README.md new file mode 100644 index 0000000..8b7873f --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# Welcome to KeySwirl + +This is my repository for lots of keyboard related things! + +| Name | Description | +| ---------------------------- | ----------------------------------- | +| [keyboards](./keyboards/qmk) | qmk configurations for my keyboards | +| [layout-lens](./layout-lens) | keyboard layout to SVG renderer | + +Some neat thingies: + +- This repository provides a nix flake for devshells and builds. +- Each keyboard contains a `lens.json` which automatically generates a prevew in CI! diff --git a/flake.nix b/flake.nix index 3ac1563..79c8889 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,15 @@ defaultPackage = packages.layout-lens; devShells.layout-lens = pkgs.callPackage ./layout-lens/shell.nix { }; devShells.qmk = pkgs.callPackage ./keyboards/qmk/shell.nix { }; + + apps.generate-layout-previews = { + type = "app"; + program = pkgs.lib.getExe (pkgs.writeShellApplication { + name = "generate-layout-previes"; + runtimeInputs = [ layout-lens ]; + text = builtins.readFile ./layout-lens/scripts/generate-layouts.sh; + }); + }; } ); } diff --git a/keyboards/qmk/ferris-sweep/README.md b/keyboards/qmk/ferris-sweep/README.md new file mode 100644 index 0000000..5f5253e --- /dev/null +++ b/keyboards/qmk/ferris-sweep/README.md @@ -0,0 +1,10 @@ +# Ferris sweep + +![layout preview](./lens.svg) + +This directory contains the configuration files for my ferris sweep! + +## Layout philosophy + +- every symbol must be accessible without having to press `shift` +- combos are awesome diff --git a/keyboards/qmk/ferris-sweep/lens.svg b/keyboards/qmk/ferris-sweep/lens.svg new file mode 100644 index 0000000..4d383e9 --- /dev/null +++ b/keyboards/qmk/ferris-sweep/lens.svg @@ -0,0 +1,517 @@ + + + + + + Q + + + ! + + + TR + + + f1 + + + + + + + A + + + < + + + 6 + + + f6 + + + + + + + X + + + > + + + + + f11 + + + + + + + W + + + @ + + + 2 + + + f2 + + + + + + + R + + + ( + + + 7 + + + f7 + + + + + + + C + + + ] + + + + + f12 + + + + + + + F + + + # + + + 3 + + + f3 + + + + + + + S + + + [ + + + 8 + + + f8 + + + + + + + D + + + ] + + + + + + + + + + + P + + + $ + + + 4 + + + f4 + + + + + + + T + + + { + + + 9 + + + f9 + + + + + + + V + + + } + + + + + + + + + + + B + + + % + + + 5 + + + f5 + + + + + + + G + + + - + + + TL + + + f10 + + + + + + + Z + + + — + + + + + + + + + + + ■ + + + + + + + + + + + + + ␣ + + + + + + + + + + + + + ⇧ + + + + + + + + + + + + + ■ + + + + + + + + + + + + + J + + + ^ + + + 🏠 + + + + + + + + + M + + + ? + + + ◄ + + + 😱 + + + + + + + K + + + + + + + 🎮 + + + + + + + L + + + & + + + ⏬ + + + 🔊 + + + + + + + N + + + _ + + + ▼ + + + 🔉 + + + + + + + H + + + | + + + + + 🔇 + + + + + + + U + + + * + + + ⏫ + + + 🔆 + + + + + + + E + + + / + + + ▲ + + + 🔅 + + + + + + + , + + + \ + + + + + + + + + + + Y + + + ~ + + + end + + + ⏪ + + + + + + + I + + + = + + + ► + + + ⏯️ + + + + + + + . + + + + + + + + + ⏩ + + + + + + + : + + + ` + + + del + + + copy + + + + + + + O + + + ; + + + + + paste + + + + + + + ' + + + " + + + + + cut + + + \ No newline at end of file diff --git a/layout-lens/README.md b/layout-lens/README.md new file mode 100644 index 0000000..1633d30 --- /dev/null +++ b/layout-lens/README.md @@ -0,0 +1,13 @@ +# Layout-lens + +> NOTE: this project cannot yet render combos, which will change soon + +This is a quickly-thrown-together set of scripts for generating SVG previews of keyboard layouts. For example configurations check out any config in the `keyboards` directory of this repository. To run this on your config simply do + +```sh +nix run github:mateiadrielrafael/keyswirl#layout-lens my-config.json out.svg +``` + +## Technical details + +The code isn't very well written (i.e.: no error handling, only contains the features I needed myself, etc). I'd rewrite this in a better language given the motivation, but the current version does the job just fine. If you want to contribute a layout preset, add it to [./src/layouts](./src/layouts) and then modify the enum in [./src/types.ts](./src/types.ts) to know about it's existence. diff --git a/layout-lens/default.nix b/layout-lens/default.nix index 0d8d355..86c31d0 100644 --- a/layout-lens/default.nix +++ b/layout-lens/default.nix @@ -1,7 +1,7 @@ { pkgs ? import { } }: pkgs.stdenv.mkDerivation { - name = "swoop"; + name = "layout-lens"; src = ./src; @@ -17,6 +17,6 @@ pkgs.stdenv.mkDerivation { installPhase = '' mkdir $out/bin -p - cp -rv out.js $out/bin/swoop + cp -rv out.js $out/bin/layout-lens ''; } diff --git a/layout-lens/package-lock.json b/layout-lens/package-lock.json index 51a851a..b58a30d 100644 --- a/layout-lens/package-lock.json +++ b/layout-lens/package-lock.json @@ -1,12 +1,9 @@ { - "name": "swoop", - "version": "1.0.0", + "name": "layout-lens", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "swoop", - "version": "1.0.0", "devDependencies": { "@types/node": "^18.11.18" } diff --git a/layout-lens/package.json b/layout-lens/package.json index 0022b5e..e513cd5 100644 --- a/layout-lens/package.json +++ b/layout-lens/package.json @@ -1,6 +1,4 @@ { - "name": "swoop", - "version": "1.0.0", "devDependencies": { "@types/node": "^18.11.18" } diff --git a/layout-lens/scripts/generate-layouts.sh b/layout-lens/scripts/generate-layouts.sh new file mode 100644 index 0000000..00082a6 --- /dev/null +++ b/layout-lens/scripts/generate-layouts.sh @@ -0,0 +1,11 @@ +shopt -s globstar # Enable the globstar option to use ** + +for config in **/lens.json; do + # Check if the path is a regular file + if [ -f "$config" ]; then + # Replace the .txt extension with a new extension (e.g., .newext) + out="${config%.json}.svg" + # Generate preview + layout-lens "$config" "$out" + fi +done