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

🌐 Try it live online: prateek-squadron.github.io/hyprconf2lua
Runs 100% client-side via WebAssembly (Pyodide) — zero installation required, your config never leaves your browser.


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, bindd, binde, bindm, bindl, bindr, bindn, bindt, bindi, bindu, bindx, bindo, bindc, bindg, etc. Correctly handles flags like { repeating = true }, { non_consuming = true }, { allow_input_capture = true }, release triggers, and extracts bindd descriptions into { description = "..." }.
  • Dispatcher Simplification: Maps native dispatchers with correct type signatures and table arguments, and automatically rewrites legacy exec, hyprctl dispatch X into direct hl.dsp.* calls to prevent per-keypress process spawning.
  • Rules & Modern Directives: Comprehensive support for windowrule, windowrulev2, layerrule, workspace, permission, and monitorv2 { ... } blocks with CSS gap tables (reserved = { top, right, bottom, left }).
  • 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

Arch Linux (AUR)

# Using paru
paru -S hyprconf2lua

# Using yay
yay -S hyprconf2lua

Via PyPI

# 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 (with Hyprland 0.56+ constructs)

# Monitor configuration (supports both directive and monitorv2 block)
monitorv2 {
    output = DP-1
    mode = 2560x1440@165
    position = 0x0
    scale = 1
    disabled = 0
    vrr = 1
}

# 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)
}

# Permissions sandbox
permission = ^(/usr/lib/xdg-desktop-portal-hyprland)$, screencopy, allow

# Keybindings (with bindd descriptions and flags)
bindd = SUPER, Return, Open terminal, exec, kitty
bindd = SUPER, Q, Close active window, killactive
bind = SUPER, M, exit
bind = SUPER, F, fullscreen, 1
bindle = , XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+

# Legacy hyprctl dispatcher rewrite (optimized to direct Lua call)
bind = SUPER, 1, exec, hyprctl dispatch workspace 1

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

Generated hyprland.lua

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

---@module 'hl'

-- Monitor configuration (supports both directive and monitorv2 block)
hl.monitor({
    output = "DP-1",
    mode = "2560x1440@165",
    position = "0x0",
    scale = 1,
    disabled = false,
    vrr = 1,
})

-- General settings
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)",
        },
    },
})

-- Permissions sandbox
hl.permission({ binary = "^(/usr/lib/xdg-desktop-portal-hyprland)$", type = "screencopy", mode = "allow" })

-- Keybindings (with bindd descriptions and flags)
hl.bind("SUPER + Return", hl.dsp.exec_cmd("kitty"), { description = "Open terminal" })
hl.bind("SUPER + Q", hl.dsp.window.close(), { description = "Close active window" })
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%+"), { locked = true, repeating = true })

-- Legacy hyprctl dispatcher rewrite (optimized to direct Lua call)
hl.bind("SUPER + 1", hl.dsp.focus({ workspace = 1 }))

-- Window Rules
hl.window_rule({
    name  = "float_34",
    match = {
        class = "^(pavucontrol)$",
    },
    float = true,
})
hl.window_rule({
    name  = "size_700_600_35",
    match = {
        class = "^(pavucontrol)$",
    },
    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.9.1

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.9.1
File Size Uploaded Provenance Actions
hyprconf2lua-1.9.1.tar.gz 42.5 kB Without provenance Details for hyprconf2lua-1.9.1.tar.gz

Built distribution (wheel)

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

Total release size: 72.5 kB

Release files / hyprconf2lua-1.9.1.tar.gz

Download URL hyprconf2lua-1.9.1.tar.gz
Size 42.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b2b46feb882802d040cfa4e7f2cbeb0b7f2264f135bc9cb08016d313df809db1
BLAKE2b-256 checksum
How to use checksums
f936baa1da34888de04face2aebe69bf5c0f1858455b39c82b1e2df80d1a5c54
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.9.1-py3-none-any.whl

Download URL hyprconf2lua-1.9.1-py3-none-any.whl
Size 29.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
771f3f031fe897702caef7d1b0053c2a44d4004051aa4c749e7283099cf66a4d
BLAKE2b-256 checksum
How to use checksums
9f0d8452f66a323ccee4928a2ab65310007bacca2eaf76f8a63fd5971c07d109
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.9.1

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