Skip to main content

Generate and apply Karabiner-Elements SpaceFN configurations

Project description

karabiner-configurator

Python library and CLI to generate Karabiner-Elements complex modifications, with support for a SpaceFN layer and hostname-based config overrides.

Install

pip install karabiner-configurator

CLI

# Apply rules to Karabiner profile and generate index.html
karabiner-configurator

# Use a custom config directory
karabiner-configurator /path/to/config

# Only generate HTML visualization
karabiner-configurator --html-only

# Apply rules without generating HTML
karabiner-configurator --no-html

# Show informative logs
karabiner-configurator --verbose

# Only show errors
karabiner-configurator --quiet

By default, the CLI looks for:

  • config.default.json (required)
  • config.<hostname>.json (optional)

Configuration is validated before rule generation; unknown definition keys fail fast with a clear error.

HTML rendering uses a Jinja template stored at karabiner_configurator/templates/keyboard.html.j2.

Library Usage

from karabiner_configurator import (
    main,
    load_config,
    apply_rules_to_karabiner,
    generate_html_keyboard,
)

config = load_config("/path/to/config")
rules = main(config["spacefn_definitions"], config["normal_definitions"])
apply_rules_to_karabiner(rules, config.get("profile_name", "VIM"))
generate_html_keyboard(config, "index.html")

Development

# Install editable package + dev tooling
pip install -e ".[dev]"

# Enable default local checks on every commit
pre-commit install

# Lint (ruff, 120 cols)
ruff check .

# Optional formatting check
ruff format --check .

# Type check (mypy)
mypy

# Run tests
python -m unittest discover -s tests -v

# Build package artifacts
python -m pip install build
python -m build

GitHub + PyPI Release Setup

The repository is prepared with:

  • CI workflow: .github/workflows/ci.yml
  • Publish workflow: .github/workflows/publish-pypi.yml
  • PEP 621 packaging in pyproject.toml

One-time setup

  1. Create a PyPI project named karabiner-configurator.
  2. In PyPI project settings, add a trusted publisher for this GitHub repo and workflow: .github/workflows/publish-pypi.yml.
  3. In GitHub, keep the pypi environment (created by workflow) or create it with your preferred protections.

Publish

  1. Bump version in pyproject.toml.
  2. Commit and push.
  3. Create and publish a GitHub Release.
  4. The Publish to PyPI workflow will build and upload the release to PyPI.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

karabiner_configurator-0.1.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

karabiner_configurator-0.1.0-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file karabiner_configurator-0.1.0.tar.gz.

File metadata

  • Download URL: karabiner_configurator-0.1.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for karabiner_configurator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fecfd7f85c8815eec886b6382862f37d37ec65473baec39f9faaf4d09ef734e3
MD5 17cd12d3bfb675062a5dcdd95e31c070
BLAKE2b-256 3b6a95882b7dff5350d0636d850716ca4e4ab15471b12e0e74701ef7d4d0645a

See more details on using hashes here.

Provenance

The following attestation bundles were made for karabiner_configurator-0.1.0.tar.gz:

Publisher: publish-pypi.yml on ea2809/karabiner-configurator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file karabiner_configurator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for karabiner_configurator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 98d5920a1d7f6c968e623a0ff829920957358a893764ee1868bafdc14a4f110b
MD5 d405af8716cbd296033a7260aabbc12e
BLAKE2b-256 5645bb8fe53d4b9ff6c01f509dad18abc1f3983b2204ef673e64c95a76adcd9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for karabiner_configurator-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on ea2809/karabiner-configurator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page