hyprconf2lua 1.8.2__tar.gz → 1.8.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. hyprconf2lua-1.8.3/PKG-INFO +266 -0
  2. hyprconf2lua-1.8.3/README.md +243 -0
  3. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/pyproject.toml +1 -1
  4. hyprconf2lua-1.8.3/src/hyprconf2lua/__init__.py +1 -0
  5. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/src/hyprconf2lua/ast.py +6 -0
  6. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/src/hyprconf2lua/codegen.py +56 -0
  7. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/src/hyprconf2lua/parser.py +59 -10
  8. hyprconf2lua-1.8.3/src/hyprconf2lua.egg-info/PKG-INFO +266 -0
  9. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/src/hyprconf2lua.egg-info/SOURCES.txt +1 -0
  10. hyprconf2lua-1.8.3/tests/test_gesture_inline.py +166 -0
  11. hyprconf2lua-1.8.2/PKG-INFO +0 -193
  12. hyprconf2lua-1.8.2/README.md +0 -170
  13. hyprconf2lua-1.8.2/src/hyprconf2lua/__init__.py +0 -1
  14. hyprconf2lua-1.8.2/src/hyprconf2lua.egg-info/PKG-INFO +0 -193
  15. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/LICENSE +0 -0
  16. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/setup.cfg +0 -0
  17. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/src/hyprconf2lua/__main__.py +0 -0
  18. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/src/hyprconf2lua/cli.py +0 -0
  19. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/src/hyprconf2lua/converter.py +0 -0
  20. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/src/hyprconf2lua/lexer.py +0 -0
  21. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/src/hyprconf2lua/mappings.py +0 -0
  22. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/src/hyprconf2lua.egg-info/dependency_links.txt +0 -0
  23. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/src/hyprconf2lua.egg-info/entry_points.txt +0 -0
  24. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/src/hyprconf2lua.egg-info/requires.txt +0 -0
  25. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/src/hyprconf2lua.egg-info/top_level.txt +0 -0
  26. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/tests/test_converter.py +0 -0
  27. {hyprconf2lua-1.8.2 → hyprconf2lua-1.8.3}/tests/test_issue54.py +0 -0
@@ -0,0 +1,266 @@
1
+ Metadata-Version: 2.4
2
+ Name: hyprconf2lua
3
+ Version: 1.8.3
4
+ Summary: Convert Hyprland hyprlang .conf files to Lua .lua config format (v0.55+)
5
+ Author: hyprconf2lua contributors
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Prateek-squadron/hyprconf2lua
8
+ Project-URL: Repository, https://github.com/Prateek-squadron/hyprconf2lua
9
+ Keywords: hyprland,hyprlang,lua,config,converter
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: End Users/Desktop
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Utilities
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest; extra == "dev"
22
+ Dynamic: license-file
23
+
24
+ # hyprconf2lua
25
+
26
+ <p align="center">
27
+ <strong>Convert Hyprland legacy <code>.conf</code> (hyprlang) configurations to modern Lua format for Hyprland v0.55+</strong>
28
+ </p>
29
+
30
+ <p align="center">
31
+ <a href="https://pypi.org/project/hyprconf2lua/"><img src="https://img.shields.io/pypi/v/hyprconf2lua.svg?color=blue" alt="PyPI version"></a>
32
+ <a href="https://pepy.tech/projects/hyprconf2lua"><img src="https://static.pepy.tech/personalized-badge/hyprconf2lua?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=BLUE&left_text=downloads" alt="PyPI Downloads"></a>
33
+ <a href="https://pypi.org/project/hyprconf2lua/"><img src="https://img.shields.io/pypi/pyversions/hyprconf2lua.svg" alt="Python versions"></a>
34
+ <a href="https://github.com/Prateek-squadron/hyprconf2lua/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
35
+ <a href="https://github.com/Prateek-squadron/hyprconf2lua/actions"><img src="https://img.shields.io/badge/tests-131%20passed-success.svg" alt="Tests status"></a>
36
+ </p>
37
+
38
+ ---
39
+
40
+ ## Overview
41
+
42
+ 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.
43
+
44
+ **`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.
45
+
46
+ Instead of unreliable regex search-and-replace, `hyprconf2lua` implements a full compiler pipeline:
47
+ ```
48
+ hyprlang source (.conf)
49
+ │
50
+ ▼
51
+ [ Lexer ] (Regex tokenizer preserving string quoting & operators)
52
+ │
53
+ ▼
54
+ [ Parser ] (Recursive descent AST generation)
55
+ │
56
+ ▼
57
+ [ Codegen ] (Idiomatic Lua code generator for `hl` module)
58
+ │
59
+ ▼
60
+ Lua config (.lua)
61
+ ```
62
+
63
+ ---
64
+
65
+ ## Features
66
+
67
+ - **Bindings & Flags**: Transpiles `bind`, `binde`, `bindm`, `bindl`, `bindr`, `bindn`, `bindt`, `bindi`, etc. Correctly handles flags like `{ repeating = true }`, `{ non_consuming = true }`, and release triggers.
68
+ - **Dispatchers**: Maps native dispatchers (`exec`, `workspace`, `movetoworkspace`, `movetoworkspacesilent`, `fullscreen`, `movefocus`, `resizeactive`, `splitratio`, `layoutmsg`, etc.) with correct type signatures and table arguments.
69
+ - **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.
70
+ - **Animations & Curves**: Directives like `animation =` and `bezier =` (including inside `animations {}` blocks) are converted into top-level `hl.animation()` and `hl.curve()` statements.
71
+ - **Variable Scoping & Expansion**: Converts Hyprland `$variables` into clean `local` Lua definitions and resolves scoped references.
72
+ - **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.
73
+ - **Audit & Coverage Report**: Built-in `--report` mode categorizes directives into translated, passthrough, and flagged items, ensuring high conversion confidence.
74
+ - **CI / Validation Mode**: `--check` returns exit code `3` if any directive requires manual intervention.
75
+ - **Zero Dependencies**: Pure Python with no third-party package dependencies.
76
+
77
+ ---
78
+
79
+ ## Installation
80
+
81
+ ### Via PyPI (Recommended)
82
+
83
+ ```bash
84
+ # Using pip
85
+ pip install --upgrade hyprconf2lua
86
+
87
+ # Using pipx (isolated application)
88
+ pipx install hyprconf2lua
89
+ ```
90
+
91
+ ### From Source
92
+
93
+ ```bash
94
+ git clone https://github.com/Prateek-squadron/hyprconf2lua.git
95
+ cd hyprconf2lua
96
+ pip install .
97
+ ```
98
+
99
+ ---
100
+
101
+ ## Quick Start & Usage
102
+
103
+ ### 1. Convert Single File
104
+
105
+ Convert your primary `hyprland.conf` to stdout or redirect to `hyprland.lua`:
106
+
107
+ ```bash
108
+ # Redirect to file
109
+ hyprconf2lua ~/.config/hypr/hyprland.conf > ~/.config/hypr/hyprland.lua
110
+
111
+ # Or specify output with --out / -o
112
+ hyprconf2lua ~/.config/hypr/hyprland.conf -o ~/.config/hypr/hyprland.lua
113
+ ```
114
+
115
+ ### 2. Standard Input / Pipe
116
+
117
+ Pipe any configuration string directly into the converter:
118
+
119
+ ```bash
120
+ cat ~/.config/hypr/hyprland.conf | hyprconf2lua > ~/.config/hypr/hyprland.lua
121
+ ```
122
+
123
+ ### 3. Convert an Entire Directory (Batch Mode)
124
+
125
+ If your Hyprland configuration is split into multiple `.conf` files (e.g., `keybinds.conf`, `rules.conf`, `monitors.conf`):
126
+
127
+ ```bash
128
+ # Walks directory and writes a sibling .lua file next to each .conf
129
+ # (safely skips existing .lua files)
130
+ hyprconf2lua --dir ~/.config/hypr/
131
+
132
+ # Overwrite existing .lua files in the directory
133
+ hyprconf2lua --dir ~/.config/hypr/ --in-place
134
+ ```
135
+
136
+ ### 4. Audit & Coverage Reporting
137
+
138
+ Print a diagnostic breakdown of translated, passthrough, and manual review directives:
139
+
140
+ ```bash
141
+ hyprconf2lua --report ~/.config/hypr/hyprland.conf > ~/.config/hypr/hyprland.lua
142
+ ```
143
+ *Output to stderr:*
144
+ ```text
145
+ Report: 84 translated, 0 passthrough, 0 flagged, 84 total, 100.0% coverage
146
+ ```
147
+
148
+ ### 5. Automated CI Check
149
+
150
+ Check whether a config translates cleanly without manual review warnings:
151
+
152
+ ```bash
153
+ hyprconf2lua --check ~/.config/hypr/hyprland.conf
154
+ ```
155
+ *Exits with code `0` if all directives translate cleanly, or `3` if any directive was flagged for manual review.*
156
+
157
+ ---
158
+
159
+ ## CLI Options Reference
160
+
161
+ | Flag | Argument | Description |
162
+ |------|----------|-------------|
163
+ | `-o`, `--out` | `<path>` | Path to output file (defaults to stdout) |
164
+ | `-d`, `--dir` | `<dir>` | Walk directory recursively, writing `.lua` next to each `.conf` |
165
+ | `--in-place` | None | When used with `--dir`, overwrite existing `.lua` sibling files |
166
+ | `--report` | None | Output translation statistics and coverage percentage to stderr |
167
+ | `--check` | None | Exit code 3 if any directive is flagged for manual review |
168
+ | `--version` | None | Display the version of `hyprconf2lua` |
169
+ | `-h`, `--help` | None | Display command help and exit |
170
+
171
+ ---
172
+
173
+ ## Conversion Example
174
+
175
+ ### Legacy `hyprland.conf`
176
+ ```ini
177
+ # General settings
178
+ general {
179
+ gaps_in = 5
180
+ gaps_out = 20
181
+ border_size = 2
182
+ col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
183
+ col.inactive_border = rgba(595959aa)
184
+ }
185
+
186
+ # Keybindings
187
+ bind = SUPER, Q, exec, kitty
188
+ bind = SUPER, C, killactive
189
+ bind = SUPER, M, exit
190
+ bind = SUPER, F, fullscreen, 1
191
+ binde = , XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+
192
+
193
+ # Window Rules
194
+ windowrulev2 = float, class:^(pavucontrol)$
195
+ windowrulev2 = size 700 600, class:^(pavucontrol)$
196
+ ```
197
+
198
+ ### Generated `hyprland.lua`
199
+ ```lua
200
+ -- Generated by hyprconf2lua v1.8.2
201
+ -- https://github.com/Prateek-squadron/hyprconf2lua
202
+ -- Manual review may be needed for complex directives
203
+
204
+ ---@module 'hl'
205
+
206
+ hl.config({
207
+ general = {
208
+ gaps_in = 5,
209
+ gaps_out = 20,
210
+ border_size = 2,
211
+ col = {
212
+ active_border = { colors = { "rgba(33ccffee)", "rgba(00ff99ee)" }, angle = 45 },
213
+ inactive_border = "rgba(595959aa)",
214
+ },
215
+ },
216
+ })
217
+
218
+ hl.bind("SUPER + Q", hl.dsp.exec_cmd("kitty"))
219
+ hl.bind("SUPER + C", hl.dsp.window.kill_active())
220
+ hl.bind("SUPER + M", hl.dsp.exit())
221
+ hl.bind("SUPER + F", hl.dsp.window.fullscreen({ mode = 1 }))
222
+ hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+"), { repeating = true })
223
+
224
+ hl.windowrule({
225
+ match = {
226
+ class = "pavucontrol",
227
+ },
228
+ float = true,
229
+ size = { 700, 600 },
230
+ })
231
+ ```
232
+
233
+ ---
234
+
235
+ ## Development & Testing
236
+
237
+ We maintain a comprehensive suite of unit and regression tests covering language syntax, edge-case escaping, variables, dispatchers, and rule combinations.
238
+
239
+ ```bash
240
+ # Clone the repository
241
+ git clone https://github.com/Prateek-squadron/hyprconf2lua.git
242
+ cd hyprconf2lua
243
+
244
+ # Run pytest test suite
245
+ python -m pytest tests/
246
+
247
+ # Build wheel and source distributions
248
+ python -m build
249
+ ```
250
+
251
+ ---
252
+
253
+ ## Contributing
254
+
255
+ Contributions, bug reports, and pull requests are warmly welcome! If you encounter any `.conf` directive or edge-case that doesn't translate as expected:
256
+
257
+ 1. Open an issue on [GitHub Issues](https://github.com/Prateek-squadron/hyprconf2lua/issues) with the problematic `.conf` snippet.
258
+ 2. Submit a pull request with a reproducible test case in `tests/test_converter.py`.
259
+
260
+ Special thanks to all international contributors and community members helping refine Hyprland's Lua ecosystem!
261
+
262
+ ---
263
+
264
+ ## License
265
+
266
+ This project is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,243 @@
1
+ # hyprconf2lua
2
+
3
+ <p align="center">
4
+ <strong>Convert Hyprland legacy <code>.conf</code> (hyprlang) configurations to modern Lua format for Hyprland v0.55+</strong>
5
+ </p>
6
+
7
+ <p align="center">
8
+ <a href="https://pypi.org/project/hyprconf2lua/"><img src="https://img.shields.io/pypi/v/hyprconf2lua.svg?color=blue" alt="PyPI version"></a>
9
+ <a href="https://pepy.tech/projects/hyprconf2lua"><img src="https://static.pepy.tech/personalized-badge/hyprconf2lua?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=BLUE&left_text=downloads" alt="PyPI Downloads"></a>
10
+ <a href="https://pypi.org/project/hyprconf2lua/"><img src="https://img.shields.io/pypi/pyversions/hyprconf2lua.svg" alt="Python versions"></a>
11
+ <a href="https://github.com/Prateek-squadron/hyprconf2lua/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
12
+ <a href="https://github.com/Prateek-squadron/hyprconf2lua/actions"><img src="https://img.shields.io/badge/tests-131%20passed-success.svg" alt="Tests status"></a>
13
+ </p>
14
+
15
+ ---
16
+
17
+ ## Overview
18
+
19
+ 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.
20
+
21
+ **`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.
22
+
23
+ Instead of unreliable regex search-and-replace, `hyprconf2lua` implements a full compiler pipeline:
24
+ ```
25
+ hyprlang source (.conf)
26
+ │
27
+ ▼
28
+ [ Lexer ] (Regex tokenizer preserving string quoting & operators)
29
+ │
30
+ ▼
31
+ [ Parser ] (Recursive descent AST generation)
32
+ │
33
+ ▼
34
+ [ Codegen ] (Idiomatic Lua code generator for `hl` module)
35
+ │
36
+ ▼
37
+ Lua config (.lua)
38
+ ```
39
+
40
+ ---
41
+
42
+ ## Features
43
+
44
+ - **Bindings & Flags**: Transpiles `bind`, `binde`, `bindm`, `bindl`, `bindr`, `bindn`, `bindt`, `bindi`, etc. Correctly handles flags like `{ repeating = true }`, `{ non_consuming = true }`, and release triggers.
45
+ - **Dispatchers**: Maps native dispatchers (`exec`, `workspace`, `movetoworkspace`, `movetoworkspacesilent`, `fullscreen`, `movefocus`, `resizeactive`, `splitratio`, `layoutmsg`, etc.) with correct type signatures and table arguments.
46
+ - **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.
47
+ - **Animations & Curves**: Directives like `animation =` and `bezier =` (including inside `animations {}` blocks) are converted into top-level `hl.animation()` and `hl.curve()` statements.
48
+ - **Variable Scoping & Expansion**: Converts Hyprland `$variables` into clean `local` Lua definitions and resolves scoped references.
49
+ - **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.
50
+ - **Audit & Coverage Report**: Built-in `--report` mode categorizes directives into translated, passthrough, and flagged items, ensuring high conversion confidence.
51
+ - **CI / Validation Mode**: `--check` returns exit code `3` if any directive requires manual intervention.
52
+ - **Zero Dependencies**: Pure Python with no third-party package dependencies.
53
+
54
+ ---
55
+
56
+ ## Installation
57
+
58
+ ### Via PyPI (Recommended)
59
+
60
+ ```bash
61
+ # Using pip
62
+ pip install --upgrade hyprconf2lua
63
+
64
+ # Using pipx (isolated application)
65
+ pipx install hyprconf2lua
66
+ ```
67
+
68
+ ### From Source
69
+
70
+ ```bash
71
+ git clone https://github.com/Prateek-squadron/hyprconf2lua.git
72
+ cd hyprconf2lua
73
+ pip install .
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Quick Start & Usage
79
+
80
+ ### 1. Convert Single File
81
+
82
+ Convert your primary `hyprland.conf` to stdout or redirect to `hyprland.lua`:
83
+
84
+ ```bash
85
+ # Redirect to file
86
+ hyprconf2lua ~/.config/hypr/hyprland.conf > ~/.config/hypr/hyprland.lua
87
+
88
+ # Or specify output with --out / -o
89
+ hyprconf2lua ~/.config/hypr/hyprland.conf -o ~/.config/hypr/hyprland.lua
90
+ ```
91
+
92
+ ### 2. Standard Input / Pipe
93
+
94
+ Pipe any configuration string directly into the converter:
95
+
96
+ ```bash
97
+ cat ~/.config/hypr/hyprland.conf | hyprconf2lua > ~/.config/hypr/hyprland.lua
98
+ ```
99
+
100
+ ### 3. Convert an Entire Directory (Batch Mode)
101
+
102
+ If your Hyprland configuration is split into multiple `.conf` files (e.g., `keybinds.conf`, `rules.conf`, `monitors.conf`):
103
+
104
+ ```bash
105
+ # Walks directory and writes a sibling .lua file next to each .conf
106
+ # (safely skips existing .lua files)
107
+ hyprconf2lua --dir ~/.config/hypr/
108
+
109
+ # Overwrite existing .lua files in the directory
110
+ hyprconf2lua --dir ~/.config/hypr/ --in-place
111
+ ```
112
+
113
+ ### 4. Audit & Coverage Reporting
114
+
115
+ Print a diagnostic breakdown of translated, passthrough, and manual review directives:
116
+
117
+ ```bash
118
+ hyprconf2lua --report ~/.config/hypr/hyprland.conf > ~/.config/hypr/hyprland.lua
119
+ ```
120
+ *Output to stderr:*
121
+ ```text
122
+ Report: 84 translated, 0 passthrough, 0 flagged, 84 total, 100.0% coverage
123
+ ```
124
+
125
+ ### 5. Automated CI Check
126
+
127
+ Check whether a config translates cleanly without manual review warnings:
128
+
129
+ ```bash
130
+ hyprconf2lua --check ~/.config/hypr/hyprland.conf
131
+ ```
132
+ *Exits with code `0` if all directives translate cleanly, or `3` if any directive was flagged for manual review.*
133
+
134
+ ---
135
+
136
+ ## CLI Options Reference
137
+
138
+ | Flag | Argument | Description |
139
+ |------|----------|-------------|
140
+ | `-o`, `--out` | `<path>` | Path to output file (defaults to stdout) |
141
+ | `-d`, `--dir` | `<dir>` | Walk directory recursively, writing `.lua` next to each `.conf` |
142
+ | `--in-place` | None | When used with `--dir`, overwrite existing `.lua` sibling files |
143
+ | `--report` | None | Output translation statistics and coverage percentage to stderr |
144
+ | `--check` | None | Exit code 3 if any directive is flagged for manual review |
145
+ | `--version` | None | Display the version of `hyprconf2lua` |
146
+ | `-h`, `--help` | None | Display command help and exit |
147
+
148
+ ---
149
+
150
+ ## Conversion Example
151
+
152
+ ### Legacy `hyprland.conf`
153
+ ```ini
154
+ # General settings
155
+ general {
156
+ gaps_in = 5
157
+ gaps_out = 20
158
+ border_size = 2
159
+ col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg
160
+ col.inactive_border = rgba(595959aa)
161
+ }
162
+
163
+ # Keybindings
164
+ bind = SUPER, Q, exec, kitty
165
+ bind = SUPER, C, killactive
166
+ bind = SUPER, M, exit
167
+ bind = SUPER, F, fullscreen, 1
168
+ binde = , XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+
169
+
170
+ # Window Rules
171
+ windowrulev2 = float, class:^(pavucontrol)$
172
+ windowrulev2 = size 700 600, class:^(pavucontrol)$
173
+ ```
174
+
175
+ ### Generated `hyprland.lua`
176
+ ```lua
177
+ -- Generated by hyprconf2lua v1.8.2
178
+ -- https://github.com/Prateek-squadron/hyprconf2lua
179
+ -- Manual review may be needed for complex directives
180
+
181
+ ---@module 'hl'
182
+
183
+ hl.config({
184
+ general = {
185
+ gaps_in = 5,
186
+ gaps_out = 20,
187
+ border_size = 2,
188
+ col = {
189
+ active_border = { colors = { "rgba(33ccffee)", "rgba(00ff99ee)" }, angle = 45 },
190
+ inactive_border = "rgba(595959aa)",
191
+ },
192
+ },
193
+ })
194
+
195
+ hl.bind("SUPER + Q", hl.dsp.exec_cmd("kitty"))
196
+ hl.bind("SUPER + C", hl.dsp.window.kill_active())
197
+ hl.bind("SUPER + M", hl.dsp.exit())
198
+ hl.bind("SUPER + F", hl.dsp.window.fullscreen({ mode = 1 }))
199
+ hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+"), { repeating = true })
200
+
201
+ hl.windowrule({
202
+ match = {
203
+ class = "pavucontrol",
204
+ },
205
+ float = true,
206
+ size = { 700, 600 },
207
+ })
208
+ ```
209
+
210
+ ---
211
+
212
+ ## Development & Testing
213
+
214
+ We maintain a comprehensive suite of unit and regression tests covering language syntax, edge-case escaping, variables, dispatchers, and rule combinations.
215
+
216
+ ```bash
217
+ # Clone the repository
218
+ git clone https://github.com/Prateek-squadron/hyprconf2lua.git
219
+ cd hyprconf2lua
220
+
221
+ # Run pytest test suite
222
+ python -m pytest tests/
223
+
224
+ # Build wheel and source distributions
225
+ python -m build
226
+ ```
227
+
228
+ ---
229
+
230
+ ## Contributing
231
+
232
+ Contributions, bug reports, and pull requests are warmly welcome! If you encounter any `.conf` directive or edge-case that doesn't translate as expected:
233
+
234
+ 1. Open an issue on [GitHub Issues](https://github.com/Prateek-squadron/hyprconf2lua/issues) with the problematic `.conf` snippet.
235
+ 2. Submit a pull request with a reproducible test case in `tests/test_converter.py`.
236
+
237
+ Special thanks to all international contributors and community members helping refine Hyprland's Lua ecosystem!
238
+
239
+ ---
240
+
241
+ ## License
242
+
243
+ This project is licensed under the [MIT License](LICENSE).
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hyprconf2lua"
7
- version = "1.8.2"
7
+ version = "1.8.3"
8
8
  description = "Convert Hyprland hyprlang .conf files to Lua .lua config format (v0.55+)"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -0,0 +1 @@
1
+ __version__ = "1.8.3"
@@ -116,6 +116,12 @@ class DeviceSection:
116
116
  class GestureDirective:
117
117
  body: List[Directive]
118
118
  line: int
119
+ # True for the one-line `gesture = ...` form, whose body keys are already
120
+ # the final hl.gesture field names. False for the legacy `gesture { }` block.
121
+ inline: bool = False
122
+ # Fields after the action that hl.gesture has no named field for:
123
+ # dispatcher arguments, or trailing fields Hyprland ignores.
124
+ extra_args: List[str] = field(default_factory=list)
119
125
 
120
126
 
121
127
  @dataclass
@@ -1015,7 +1015,21 @@ class Codegen:
1015
1015
  self.dedent()
1016
1016
  self.emit("})")
1017
1017
 
1018
+ # hl.gesture fields Hyprland reads as numbers or booleans; every other
1019
+ # field is read with a string parser, so it is emitted as a string.
1020
+ _GESTURE_NUMBER_FIELDS = {"fingers", "scale"}
1021
+ _GESTURE_BOOL_FIELDS = {"disable_inhibit"}
1022
+
1023
+ def _gesture_field_val(self, key: str, val: str) -> str:
1024
+ if key in self._GESTURE_NUMBER_FIELDS or key in self._GESTURE_BOOL_FIELDS or "$" in val:
1025
+ return self.to_lua_val(val)
1026
+ escaped = val.replace("\\", "\\\\").replace('"', '\\"')
1027
+ return f'"{escaped}"'
1028
+
1018
1029
  def visit_gesture(self, stmt: GestureDirective):
1030
+ if stmt.inline:
1031
+ self._visit_inline_gesture(stmt)
1032
+ return
1019
1033
  self.translated_count += 1
1020
1034
  props = {}
1021
1035
  for d in stmt.body:
@@ -1031,6 +1045,48 @@ class Codegen:
1031
1045
  self.dedent()
1032
1046
  self.emit("})")
1033
1047
 
1048
+ def _visit_inline_gesture(self, stmt: GestureDirective):
1049
+ self.translated_count += 1
1050
+ fields = {d.key: d.value[0] for d in stmt.body if isinstance(d, Directive) and d.value}
1051
+
1052
+ notes = []
1053
+ if "scale" in fields:
1054
+ # hyprlang clamps scale to [0.1, 10]; hl.gesture rejects values
1055
+ # outside [-10, -0.1] U [0.1, 10] instead, so clamp here to match.
1056
+ try:
1057
+ raw = float(fields["scale"])
1058
+ clamped = min(max(raw, 0.1), 10.0)
1059
+ if clamped != raw:
1060
+ notes.append(f"-- NOTE: scale {fields['scale']} clamped to {clamped:g}, as Hyprland's .conf parser does")
1061
+ fields["scale"] = f"{clamped:g}"
1062
+ except ValueError:
1063
+ pass
1064
+
1065
+ body = [f"[{self.quote(k)}] = {self._gesture_field_val(k, v)}," for k, v in fields.items()]
1066
+
1067
+ if fields.get("action") == "dispatcher":
1068
+ # hl.gesture has no string form for dispatcher gestures; it takes
1069
+ # `action = function() ... end`, which needs a human to write.
1070
+ self._reclassify_as_flagged()
1071
+ self.emit(f"-- TODO: manual review (gesture dispatcher: {', '.join(stmt.extra_args)}); "
1072
+ "hl.gesture needs action = function() ... end")
1073
+ self.emit("-- hl.gesture({")
1074
+ for line in body:
1075
+ self.emit(f"-- {line}")
1076
+ self.emit("-- })")
1077
+ return
1078
+
1079
+ if stmt.extra_args:
1080
+ notes.append(f"-- NOTE: Hyprland ignores trailing gesture field(s): {', '.join(stmt.extra_args)}")
1081
+ for note in notes:
1082
+ self.emit(note)
1083
+ self.emit("hl.gesture({")
1084
+ self.indent()
1085
+ for line in body:
1086
+ self.emit(line)
1087
+ self.dedent()
1088
+ self.emit("})")
1089
+
1034
1090
  def visit_submap(self, stmt: SubmapDef):
1035
1091
  self.translated_count += 1
1036
1092
  self.emit(f'hl.define_submap({self.quote(stmt.name)}, function()')