caksoylar / keymap-drawer

Visualize keymaps that use advanced features like hold-taps and combos, with automatic parsing
https://caksoylar.github.io/keymap-drawer
MIT License
718 stars 60 forks source link

parse: keyboard name detection fails for files in nix store #84

Closed MattSturgeon closed 7 months ago

MattSturgeon commented 7 months ago

keymap parse tries to guess the keyboard name by looking for the keymap filename (without extension) in zmk_keyboard_layouts.yaml.

This fails when the filename has additional prefixed/suffixed text. For example, if the file is in the /nix/store the filename is likely to have a NAR hash prefix:

trace:
    basename is "glove80.keymap"
    path "/nix/store/3c3kn02n760mlhf9bn5zgbzr07ch696s-glove80.keymap"
    python `path.stem` is "3c3kn02n760mlhf9bn5zgbzr07ch696s-glove80"

(Internally, nix ignores the NAR hash when reporting basename).

Potential solutions:

QMK

I assume this also applies to QMK

caksoylar commented 7 months ago

I don't know the best way to resolve this right now, is there a "compatibility mode" or something you can use when installing so the filenames aren't modified? I imagine this is a common issue.

You can always override the chosen layout via the command line switches, see keymap draw --help or under each section in https://github.com/caksoylar/keymap-drawer/blob/main/KEYMAP_SPEC.md#layout.

You might still run into issues with utilizing the QMK layout files in https://github.com/caksoylar/keymap-drawer/tree/main/resources/qmk_layouts, or even layouts that get downloaded then cached (depending on whether the cache folder has similar behavior).

MattSturgeon commented 7 months ago

For now I'm making a temporary symlink pointing to the nix-store file, so the name format is correct, so there's no major rush. I'll remove that though once I have a better solution.

In my specific case I probably could just specify a qmk info.json explicitly, I believe moergo publish one somewhere for the glove80...

Personally I think a more lenient auto detector would be an improvement, but I'll understand if you'd rather not have that.

caksoylar commented 7 months ago

In my specific case I probably could just specify a qmk info.json explicitly, I believe moergo publish one somewhere for the glove80...

You can copy and use this one explicitly: https://github.com/caksoylar/keymap-drawer/blob/main/resources/qmk_layouts/glove80.json

caksoylar commented 7 months ago

Since you no longer need this and I don't have the knowledge/resources to investigate nix things, I'll close this one. Anyone else that has nix troubles related to this feel free to comment and I can reopen.