Metadata-Version: 2.4
Name: karabiner-configurator
Version: 0.1.0
Summary: Generate and apply Karabiner-Elements SpaceFN configurations
Author: Enrique
License: MIT License
        
        Copyright (c) 2026 Enrique
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Keywords: karabiner,keyboard,macos,automation
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: jinja2>=3.1
Provides-Extra: dev
Requires-Dist: mypy>=1.11.0; extra == "dev"
Requires-Dist: pre-commit>=3.8.0; extra == "dev"
Requires-Dist: ruff>=0.6.0; extra == "dev"
Dynamic: license-file

# karabiner-configurator

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

## Install

```bash
pip install karabiner-configurator
```

## CLI

```bash
# 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

```python
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

```bash
# 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
