Skip to content

seanrobmerriam/hypr2lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hypr2lua

Converts Hyprlang .conf files to the Hyprland .lua config format (v0.55+).

Installation

cargo install hypr2lua

Usage

hypr2lua <input.conf> [output.lua]

If no output path is given, the input file's extension is replaced with .lua.

Conversions

Hyprlang (.conf) Lua (.lua)
# comment -- comment
$mod = SUPER local mod = "SUPER"
$mod references resolved inline
section { key = val } hl.set { section = { key = val } }
dotted.key = val nested tables
bind = MOD, K, exec, cmd hl.bind("MOD", "K", "exec", "cmd")
bindl/bindm/bindr/bindle/bindlr hl.bindl/bindm/bindr/bindle/bindlr(...)
bindd/bindeld/bindld/binddr/bindmd hl.bindd/bindeld/bindld/binddr/bindmd(...)
exec-once = cmd hl.exec_once("cmd")
exec = cmd hl.exec("cmd")
windowrule = rule, match hl.windowrule("rule", "match")
windowrulev2 = rule, match hl.windowrulev2("rule", "match")
windowrule { ... } block hl.windowrule { ... } with nested match table
monitor = ... hl.monitor(...)
bezier = ... hl.bezier(...)
animation = ... hl.animation(...)
workspace = ... hl.workspace(...)
layerrule = ... hl.layerrule(...)
env = KEY,VALUE hl.env("KEY", "VALUE")
unbind = ... hl.unbind(...)
source = path/to/file.conf require("path/to/file")
autogenerated = 1 stripped

Building

cargo build --release

The binary is at target/release/hypr2lua.

Example

Input (hyprland.conf):

$mod = SUPER
$terminal = kitty

general {
    gaps_in = 5
    gaps_out = 20
    border_size = 2
}

bind = $mod, Q, exec, $terminal
exec-once = waybar
source = ~/.config/hypr/colors.conf

Output (hyprland.lua):

-- Generated by hypr2lua from hyprlang .conf
-- Hyprland Lua config (v0.55+)

local mod = "SUPER"
local terminal = "kitty"

hl.set {
    general = {
        gaps_in = 5,
        gaps_out = 20,
        border_size = 2,
    },
}

hl.bind("SUPER", "Q", "exec", "kitty")
hl.exec_once("waybar")
require("~/.config/hypr/colors")

Library Usage

Add to your Cargo.toml:

[dependencies]
hypr2lua = "0.1"
use hypr2lua::{parse, generate};

let conf = r#"
$mod = SUPER

general {
    gaps_in = 5
}

bind = $mod, Q, exec, foot
"#;

let nodes = parse(conf);
let lua = generate(&nodes);
println!("{}", lua);

License

MIT

Releases

Packages

Contributors

Languages