Add headless CLI for uploading/downloading keyboard configurations - #383
Open
joshperry wants to merge 2 commits into
Open
Add headless CLI for uploading/downloading keyboard configurations#383joshperry wants to merge 2 commits into
joshperry wants to merge 2 commits into
Conversation
|
This is actually really useful. For some reason, my keyboard's persistent memory corrupts when rebooting (I think it's because I use a cheap USB hud), so I have to manually open Vial and load my last saved layout. This PR would allow me to automate that process on startup. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
vial-cli, a headless command-line interface for writing and reading.villayout files without launching the GUI. This enables scripted keyboard configuration, LLM MCP, remote/SSH workflows, and CI-driven provisioning on systems without a display server.Usage
How it works
This builds on the protocol/GUI decoupling from #382 (deguify) — since the protocol layer no longer imports Qt at module level, the CLI can drive
Keyboard.save_layout()andKeyboard.restore_layout()directly over USB without any display dependencies.Two things that still needed Qt are handled at runtime:
sys.modulesbefore any protocol code runs. It prints the key positions to hold and polls in a text loop instead of showing the Qt dialog.qmk_settings.jsondirectly, bypassing the GUI'sappctx-based resource resolution.Device discovery
When zero or multiple keyboards are detected, the CLI prints actionable diagnostics (troubleshooting hints for zero, a numbered device list for multiple) and exits non-zero.
UID matching
.vilfiles store keyboard UIDs as JSON numbers, which lose precision through float64 when created by JavaScript-based tools (e.g. the web configurator). The CLI compares UIDs throughfloat()to tolerate this, and supports--forceas an explicit override.Tests
20 new tests in
test_cli.pycovering device discovery (all 6 branches), upload validation, the float64 UID edge case, headless unlock flow, download round-trip, and an AST check thatcli.pyremains Qt-free.