Skip to main content

hyprconf2lua

Convert Hyprland legacy .conf (hyprlang) configurations to modern Lua format for Hyprland v0.55+

PyPI version PyPI Downloads Python versions License: MIT CI status


Overview

Starting with Hyprland v0.55+, native Lua configuration scripting is officially supported via the hl Lua module. Configuring Hyprland with Lua brings powerful benefits: programmatic loop generation, structured tables, conditional monitor setup, dynamic workspace handling, and modular imports.

hyprconf2lua is a fast, zero-dependency AST transpiler that takes your existing hyprland.conf (and any sourced split files) and converts them into idiomatic, valid, and clean Lua configuration files.

Instead of unreliable regex search-and-replace, hyprconf2lua implements a full compiler pipeline:

hyprlang source (.conf)
      │
      ▼
   [ Lexer ]      (Regex tokenizer preserving string quoting & operators)
      │
      ▼
  [ Parser ]     (Recursive descent AST generation)
      │
      ▼
  [ Codegen ]    (Idiomatic Lua code generator for `hl` module)
      │
      ▼
 Lua config (.lua)

Features

  • Bindings & Flags: Transpiles bind, binde, bindm, bindl, bindr, bindn, bindt, bindi, etc. Correctly handles flags like { repeating = true }, { non_consuming = true }, and release triggers.
  • Dispatchers: Maps native dispatchers (exec, workspace, movetoworkspace, movetoworkspacesilent, fullscreen, movefocus, resizeactive, splitratio, layoutmsg, etc.) with correct type signatures and table arguments.
  • Window Rules & Layer Rules: Comprehensive support for both windowrule and windowrulev2, as well as layerrule. Multi-word values (size, move, opacity) are converted into Lua tables.
  • Animations & Curves: Directives like animation = and bezier = (including inside animations {} blocks) are converted into top-level hl.animation() and hl.curve() statements.
  • Variable Scoping & Expansion: Converts Hyprland $variables into clean local Lua definitions and resolves scoped references.
  • Recursive Directory Walk: Convert entire multi-file config directories (--dir) in one command. Missing .lua files are created safely without overwriting existing manual edits unless --in-place is specified.
  • Audit & Coverage Report: Built-in --report mode categorizes directives into translated, passthrough, and flagged items, ensuring high conversion confidence.
  • CI / Validation Mode: --check returns exit code 3 if any directive requires manual intervention.
  • Security Hardened: Strict Lua string-escape validation, os.getenv injection protection, symlink write-target protection (--dir / -o), and bounded parser nesting depth (MAX_BLOCK_DEPTH = 64).
  • Zero Dependencies: Pure Python with no third-party package dependencies.

Installation

# Using pip
pip install --upgrade hyprconf2lua

# Using pipx (isolated application)
pipx install hyprconf2lua

From Source

git clone https://github.com/Prateek-squadron/hyprconf2lua.git
cd hyprconf2lua
pip install .

Quick Start & Usage

1. Convert Single File

Convert your primary hyprland.conf to stdout or redirect to hyprland.lua:

# Redirect to file
hyprconf2lua ~/.config/hypr/hyprland.conf > ~/.config/hypr/hyprland.lua

# Or specify output with --out / -o
hyprconf2lua ~/.config/hypr/hyprland.conf -o ~/.config/hypr/hyprland.lua

2. Standard Input / Pipe

Pipe any configuration string directly into the converter:

cat ~/.config/hypr/hyprland.conf | hyprconf2lua > ~/.config/hypr/hyprland.lua

3. Convert an Entire Directory (Batch Mode)

If your Hyprland configuration is split into multiple .conf files (e.g., keybinds.conf, rules.conf, monitors.conf):

# Walks directory and writes a sibling .lua file next to each .conf
# (safely skips existing .lua files)
hyprconf2lua --dir ~/.config/hypr/

# Overwrite existing .lua files in the directory
hyprconf2lua --dir ~/.config/hypr/ --in-place

4. Audit & Coverage Reporting

Print a diagnostic breakdown of translated, passthrough, and manual review directives:

hyprconf2lua --report ~/.config/hypr/hyprland.conf > ~/.config/hypr/hyprland.lua

Output to stderr:

Report: 84 translated, 0 passthrough, 0 flagged, 84 total, 100.0% coverage

5. Automated CI Check

Check whether a config translates cleanly without manual review warnings:

hyprconf2lua --check ~/.config/hypr/hyprland.conf

Exits with code 0 if all directives translate cleanly, or 3 if any directive was flagged for manual review.


CLI Options Reference

Flag Argument Description
-o, --out <path> Path to output file (defaults to stdout)
-d, --dir <dir> Walk directory recursively, writing .lua next to each .conf
--in-place None When used with --dir, overwrite existing .lua sibling files
--report None Output translation statistics and coverage percentage to stderr
--check None Exit code 3 if any directive is flagged for manual review
--version None Display the version of hyprconf2lua
-h, --help None Display command help and exit

Conversion Example

Legacy hyprland.conf

# General settings
general {
    gaps_in = 5
    gaps_out = 20
    border_size = 2
    col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
    col.inactive_border = rgba(595959aa)
}

# Keybindings
bind = SUPER, Q, exec, kitty
bind = SUPER, C, killactive
bind = SUPER, M, exit
bind = SUPER, F, fullscreen, 1
binde = , XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+

# Window Rules
windowrulev2 = float, class:^(pavucontrol)$
windowrulev2 = size 700 600, class:^(pavucontrol)$

Generated hyprland.lua

-- Generated by hyprconf2lua v1.8.2
-- https://github.com/Prateek-squadron/hyprconf2lua
-- Manual review may be needed for complex directives

---@module 'hl'

hl.config({
    general = {
        gaps_in = 5,
        gaps_out = 20,
        border_size = 2,
        col = {
            active_border = { colors = { "rgba(33ccffee)", "rgba(00ff99ee)" }, angle = 45 },
            inactive_border = "rgba(595959aa)",
        },
    },
})

hl.bind("SUPER + Q", hl.dsp.exec_cmd("kitty"))
hl.bind("SUPER + C", hl.dsp.window.kill_active())
hl.bind("SUPER + M", hl.dsp.exit())
hl.bind("SUPER + F", hl.dsp.window.fullscreen({ mode = 1 }))
hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+"), { repeating = true })

hl.windowrule({
    match = {
        class = "pavucontrol",
    },
    float = true,
    size = { 700, 600 },
})

Development & Testing

We maintain a comprehensive suite of unit and regression tests covering language syntax, edge-case escaping, variables, dispatchers, and rule combinations.

# Clone the repository
git clone https://github.com/Prateek-squadron/hyprconf2lua.git
cd hyprconf2lua

# Run pytest test suite
python -m pytest tests/

# Build wheel and source distributions
python -m build

Contributing

Contributions, bug reports, and pull requests are warmly welcome! If you encounter any .conf directive or edge-case that doesn't translate as expected:

  1. Open an issue on GitHub Issues with the problematic .conf snippet.
  2. Submit a pull request with a reproducible test case in tests/test_converter.py.

Special thanks to all international contributors and community members helping refine Hyprland's Lua ecosystem!


License

This project is licensed under the MIT License.

Metadata

Release files for hyprconf2lua 1.8.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hyprconf2lua 1.8.4
File Size Uploaded Provenance Actions
hyprconf2lua-1.8.4.tar.gz 37.6 kB Without provenance Details for hyprconf2lua-1.8.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hyprconf2lua 1.8.4
File Interpreter ABI Platform Actions
hyprconf2lua-1.8.4-py3-none-any.whl Python 3 none any Details for hyprconf2lua-1.8.4-py3-none-any.whl

Total release size: 65.2 kB

Release files / hyprconf2lua-1.8.4.tar.gz

Download URL hyprconf2lua-1.8.4.tar.gz
Size 37.6 kB
Tags Source
SHA-256 checksum
How to use checksums
26cb004f3f92b425a3e05a04c0dac763952909e83c3fd60170b86fb6de7586d3
BLAKE2b-256 checksum
How to use checksums
62f30cc75906c097a34fd055e0898ca3b6aa772dc2f34883590e8d44e11e8c70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.8

Release files / hyprconf2lua-1.8.4-py3-none-any.whl

Download URL hyprconf2lua-1.8.4-py3-none-any.whl
Size 27.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ffe9bd7468cd9f6c707f313d1d31868b6c6461480907b47b22e8986dc493750e
BLAKE2b-256 checksum
How to use checksums
4284807d7476afd9dfb96450a801d428438f975b58d30a7a3a7e59a5666d6f47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.8

Security for hyprconf2lua 1.8.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page