hyprconf2lua 1.7.0__tar.gz → 1.8.1__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.
- hyprconf2lua-1.8.1/PKG-INFO +193 -0
- hyprconf2lua-1.8.1/README.md +170 -0
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/pyproject.toml +1 -1
- hyprconf2lua-1.8.1/src/hyprconf2lua/__init__.py +1 -0
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/src/hyprconf2lua/codegen.py +51 -13
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/src/hyprconf2lua/lexer.py +2 -2
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/src/hyprconf2lua/mappings.py +5 -3
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/src/hyprconf2lua/parser.py +5 -5
- hyprconf2lua-1.8.1/src/hyprconf2lua.egg-info/PKG-INFO +193 -0
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/src/hyprconf2lua.egg-info/SOURCES.txt +2 -1
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/tests/test_converter.py +5 -2
- hyprconf2lua-1.8.1/tests/test_issue54.py +11 -0
- hyprconf2lua-1.7.0/PKG-INFO +0 -245
- hyprconf2lua-1.7.0/README.md +0 -222
- hyprconf2lua-1.7.0/src/hyprconf2lua/__init__.py +0 -1
- hyprconf2lua-1.7.0/src/hyprconf2lua.egg-info/PKG-INFO +0 -245
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/LICENSE +0 -0
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/setup.cfg +0 -0
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/src/hyprconf2lua/__main__.py +0 -0
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/src/hyprconf2lua/ast.py +0 -0
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/src/hyprconf2lua/cli.py +0 -0
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/src/hyprconf2lua/converter.py +0 -0
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/src/hyprconf2lua.egg-info/dependency_links.txt +0 -0
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/src/hyprconf2lua.egg-info/entry_points.txt +0 -0
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/src/hyprconf2lua.egg-info/requires.txt +0 -0
- {hyprconf2lua-1.7.0 → hyprconf2lua-1.8.1}/src/hyprconf2lua.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hyprconf2lua
|
|
3
|
+
Version: 1.8.1
|
|
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 - Knowledge Base
|
|
25
|
+
|
|
26
|
+
**Project:** hyprconf2lua
|
|
27
|
+
**Version:** 1.7.0
|
|
28
|
+
**Description:** Convert Hyprland hyprlang `.conf` files to Lua `.lua` config format (v0.55+)
|
|
29
|
+
**Maintainer:** Prateek-squadron
|
|
30
|
+
**License:** MIT
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Project Overview
|
|
35
|
+
|
|
36
|
+
hyprconf2lua is a converter that transforms Hyprland configuration files (`.conf` using hyprlang syntax) into Lua configuration files (`.lua`) compatible with Hyprland v0.55+.
|
|
37
|
+
|
|
38
|
+
The converter uses a pipeline architecture:
|
|
39
|
+
```
|
|
40
|
+
Input (.conf source)
|
|
41
|
+
├── lexer.py → tokenize source into tokens
|
|
42
|
+
├── parser.py → parse tokens into AST
|
|
43
|
+
├── codegen.py → generate Lua code from AST
|
|
44
|
+
└── Output (.lua)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Project Structure
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
hyprconf2lua/
|
|
53
|
+
├── README.md ← This knowledge base
|
|
54
|
+
├── pyproject.toml ← Package metadata, version 1.7.0
|
|
55
|
+
├── src/
|
|
56
|
+
│ ├── hyprconf2lua/
|
|
57
|
+
│ │ ├── __init__.py ← __version__ = "1.7.0"
|
|
58
|
+
│ │ ├── __main__.py ← Entry point: cli.main()
|
|
59
|
+
│ │ ├── cli.py ← CLI: argparse, file I/O, --check, --version
|
|
60
|
+
│ │ ├── converter.py ← Pipeline orchestrator: tokenize → parse → codegen
|
|
61
|
+
│ │ ├── codegen.py ← Code generator: AST → Lua string output
|
|
62
|
+
│ │ ├── lexer.py ← Regex-based tokenizer: 17 token types
|
|
63
|
+
│ │ ├── parser.py ← Recursive descent parser: 20+ parse methods
|
|
64
|
+
│ │ ├── ast.py ← 21 AST node dataclasses
|
|
65
|
+
│ │ ├── mappings.py ← Dispatcher maps, rule maps, flag mappings
|
|
66
|
+
│ │ └── mappings.py ← 5 mapping dicts (DISPATCHER_MAP, etc.)
|
|
67
|
+
│ └── tests/
|
|
68
|
+
│ ├── __init__.py
|
|
69
|
+
│ └── test_converter.py ← 106 tests passing
|
|
70
|
+
├── dist/ ← Built wheels and sdist
|
|
71
|
+
├── example/ ← Example hyprland.conf
|
|
72
|
+
├── hyprconf2lua.sh ← Shell wrapper to run without pip install
|
|
73
|
+
├── install.sh ← Symlinks hyprconf2lua.sh into PATH
|
|
74
|
+
├── LICENSE
|
|
75
|
+
├── README.md ← This knowledge base
|
|
76
|
+
└── README_kb.md ← (this file)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## v1.7.0 Fixes (Released)
|
|
82
|
+
|
|
83
|
+
All issues from the open PRs have been resolved in release **1.7.0**. Here's what was fixed:
|
|
84
|
+
|
|
85
|
+
### #35 - 7 Bug Fixes
|
|
86
|
+
1. **Window rules: match/swap** - match criteria and properties were swapped; now correctly separates `match:`-prefixed criteria from property rules
|
|
87
|
+
2. **Layer rules**: `blur=on = true` invalid Lua fixed; now emits `blur = true`
|
|
88
|
+
3. **Gestures**: nested inside `hl.config()` instead of `hl.gesture()` → now emitted as dedicated `hl.gesture({...})` calls
|
|
89
|
+
4. **Window move binds**: emitted raw tables instead of `hl.dsp.window.move()`; direction shorthand (`l`/`r`/`u`/`d`) expanded to `left`/`right`/`up`/`down`
|
|
90
|
+
5. **resizeactive binds**: now maps to `hl.dsp.window.resize({ x, y, relative = true })`
|
|
91
|
+
6. **Workspace-restore `+0`**: `+0` mapped to `workspace = "+0"` instead of `direction = "+0"`
|
|
92
|
+
7. **layoutmsg with trailing comment**: `layoutmsg, # dwindle` no longer parses argument as `nil`; flagged for manual review instead of crashing
|
|
93
|
+
|
|
94
|
+
### #38 - Windowrule/Layerrule Multi-word Values
|
|
95
|
+
- `workspace = "3 silent"` stays as string (not split into array)
|
|
96
|
+
- `size = 700 600`, `move 100%-433 53`, `opacity 0.9 0.8` → arrays `{700, 600}`, `{100%-433, 53}`, `{0.9, 0.8}`
|
|
97
|
+
|
|
98
|
+
### #39 - Animations Inside Sections
|
|
99
|
+
- `animation =`, `bezier =` directives inside `animations {}` now translate to `hl.animation()`/`hl.curve()` statements
|
|
100
|
+
- on/off flag → `enabled = true/false`
|
|
101
|
+
- styles like `popin 87%` preserved as `style = "popin 87%"`
|
|
102
|
+
- Statements emitted **outside** the `hl.config({})` table (valid Lua)
|
|
103
|
+
|
|
104
|
+
### #40 - Stdin Hyphen Whitespace
|
|
105
|
+
- `grim -c -g "$(slurp)" - | satty --filename -` preserves spaces around `-` and `|`
|
|
106
|
+
- Before: `grim -c -g \"$(slurp)\"-| satty --filename-` (spaces stripped)
|
|
107
|
+
|
|
108
|
+
### #33 - Comma in Variable Values
|
|
109
|
+
- `$kbNextWs = Ctrl+Super, right` parses correctly → `local kbNextWs = "Ctrl+Super, right"`
|
|
110
|
+
- Before: `kbNextWs = { }` (empty table)
|
|
111
|
+
|
|
112
|
+
### #32 - rgba() Color Parsing
|
|
113
|
+
- `shadow:color = rgba(0,0,0,0.85)` parses correctly
|
|
114
|
+
- Colon-paths expand to nested tables: `shadow = { color = "rgba(0,0,0,0.85)" }`
|
|
115
|
+
|
|
116
|
+
### #42 - movecurrentworkspacetomonitor Dispatcher
|
|
117
|
+
- New dispatcher: `hl.dsp.workspace.move({ monitor = "l" })`
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Test Results
|
|
122
|
+
|
|
123
|
+
- **106 tests passing** (only pre-existing `test_cli_help` fails due to module not being installed in /usr/bin/python path)
|
|
124
|
+
- All fixes verified against real-world hyprland configs
|
|
125
|
+
- Regressions: 0 (all existing tests continue to pass)
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## How to Build & Test
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# From project root
|
|
133
|
+
python -m build # Build sdist + wheel
|
|
134
|
+
python -m pytest tests/ # Run all 106 tests
|
|
135
|
+
python -m hyprconf2lua # CLI help
|
|
136
|
+
|
|
137
|
+
# Example conversions
|
|
138
|
+
hyprconf2lua example/hyprland.conf
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Guidelines for AI Agents Working on This Project
|
|
144
|
+
|
|
145
|
+
### Code Style
|
|
146
|
+
- Follow existing patterns in `src/hyprconf2lua/`
|
|
147
|
+
- Use `no_space_before` / `no_space_after` sets in `_join_tokens` for consistent spacing
|
|
148
|
+
- Keep `MULTI_VALUE_EFFECT_KEYS = {"move", "size", "opacity", "alpha"}` for multi-word effect values
|
|
149
|
+
- Dispatcher maps in `mappings.py` - add new dispatchers there
|
|
150
|
+
|
|
151
|
+
### Adding New Dispatchers
|
|
152
|
+
1. Add to `DISPATCHER_MAP` in `mappings.py` with `(func_string, needs_args)`
|
|
153
|
+
2. Handle in `build_dispatcher()` and `build_dispatcher_args()` in `codegen.py`
|
|
154
|
+
3. Add special cases for known patterns (e.g., `+0` → workspace, `l/r/u/d` → directions)
|
|
155
|
+
|
|
156
|
+
### Adding New Rule Types
|
|
157
|
+
1. Add to `WINDOW_RULE_MAP` or `LAYER_RULE_MAP` in `mappings.py`
|
|
158
|
+
2. Handle in `visit_windowrule()` / `visit_layerrule()` in `codegen.py`
|
|
159
|
+
3. Support both old-style (`rule, match:X`) and new-style (`match:key X`) syntax
|
|
160
|
+
|
|
161
|
+
### Adding New Animations/Beziers
|
|
162
|
+
1. Add `enabled` field to `AnimationDirective` in `ast.py`
|
|
163
|
+
2. Update `parse_animation()` in `parser.py` to extract `enabled`, `style` from comma values
|
|
164
|
+
3. Update `visit_animation()` in `codegen.py` to use `stmt.enabled` and `stmt.style`
|
|
165
|
+
4. Ensure statements are emitted **outside** `hl.config({})` table (see `emit_section_config`)
|
|
166
|
+
|
|
167
|
+
### Testing
|
|
168
|
+
- Run `python -m pytest tests/` to verify all 106 tests pass
|
|
169
|
+
- Add regression tests in `tests/test_converter.py` for new fixes
|
|
170
|
+
- Test with real hyprland configs via `hyprctl configerrors`
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Recent Changes History
|
|
175
|
+
|
|
176
|
+
| Version | Date | Key Fixes |
|
|
177
|
+
|---------|------|-----------|
|
|
178
|
+
| **1.7.0** | 2026-08-24 | All 7 bugs from #35, #38, #39, #40, #33, #32 fixed |
|
|
179
|
+
| **1.6.0** | 2026-08-20 | #26-#29 (source path, hyphens, ${} syntax, multiline exec) |
|
|
180
|
+
| **1.5.0** | 2026-08-28 | #24/#25 (hyphen→underscore, $HOME→os.getenv) |
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Contact & Support
|
|
185
|
+
|
|
186
|
+
- **GitHub:** https://github.com/Prateek-squadron/hyprconf2lua
|
|
187
|
+
- **PyPI:** https://pypi.org/project/hyprconf2lua/
|
|
188
|
+
- **Issues:** Use GitHub Issues for bug reports and feature requests
|
|
189
|
+
- **IRC/Slack:** #hyprland on Libera.Chat (project maintainer)
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
*This knowledge base was created for the v1.7.0 release cycle. For the latest updates, check the GitHub repository.*
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# hyprconf2lua - Knowledge Base
|
|
2
|
+
|
|
3
|
+
**Project:** hyprconf2lua
|
|
4
|
+
**Version:** 1.7.0
|
|
5
|
+
**Description:** Convert Hyprland hyprlang `.conf` files to Lua `.lua` config format (v0.55+)
|
|
6
|
+
**Maintainer:** Prateek-squadron
|
|
7
|
+
**License:** MIT
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Project Overview
|
|
12
|
+
|
|
13
|
+
hyprconf2lua is a converter that transforms Hyprland configuration files (`.conf` using hyprlang syntax) into Lua configuration files (`.lua`) compatible with Hyprland v0.55+.
|
|
14
|
+
|
|
15
|
+
The converter uses a pipeline architecture:
|
|
16
|
+
```
|
|
17
|
+
Input (.conf source)
|
|
18
|
+
├── lexer.py → tokenize source into tokens
|
|
19
|
+
├── parser.py → parse tokens into AST
|
|
20
|
+
├── codegen.py → generate Lua code from AST
|
|
21
|
+
└── Output (.lua)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Project Structure
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
hyprconf2lua/
|
|
30
|
+
├── README.md ← This knowledge base
|
|
31
|
+
├── pyproject.toml ← Package metadata, version 1.7.0
|
|
32
|
+
├── src/
|
|
33
|
+
│ ├── hyprconf2lua/
|
|
34
|
+
│ │ ├── __init__.py ← __version__ = "1.7.0"
|
|
35
|
+
│ │ ├── __main__.py ← Entry point: cli.main()
|
|
36
|
+
│ │ ├── cli.py ← CLI: argparse, file I/O, --check, --version
|
|
37
|
+
│ │ ├── converter.py ← Pipeline orchestrator: tokenize → parse → codegen
|
|
38
|
+
│ │ ├── codegen.py ← Code generator: AST → Lua string output
|
|
39
|
+
│ │ ├── lexer.py ← Regex-based tokenizer: 17 token types
|
|
40
|
+
│ │ ├── parser.py ← Recursive descent parser: 20+ parse methods
|
|
41
|
+
│ │ ├── ast.py ← 21 AST node dataclasses
|
|
42
|
+
│ │ ├── mappings.py ← Dispatcher maps, rule maps, flag mappings
|
|
43
|
+
│ │ └── mappings.py ← 5 mapping dicts (DISPATCHER_MAP, etc.)
|
|
44
|
+
│ └── tests/
|
|
45
|
+
│ ├── __init__.py
|
|
46
|
+
│ └── test_converter.py ← 106 tests passing
|
|
47
|
+
├── dist/ ← Built wheels and sdist
|
|
48
|
+
├── example/ ← Example hyprland.conf
|
|
49
|
+
├── hyprconf2lua.sh ← Shell wrapper to run without pip install
|
|
50
|
+
├── install.sh ← Symlinks hyprconf2lua.sh into PATH
|
|
51
|
+
├── LICENSE
|
|
52
|
+
├── README.md ← This knowledge base
|
|
53
|
+
└── README_kb.md ← (this file)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## v1.7.0 Fixes (Released)
|
|
59
|
+
|
|
60
|
+
All issues from the open PRs have been resolved in release **1.7.0**. Here's what was fixed:
|
|
61
|
+
|
|
62
|
+
### #35 - 7 Bug Fixes
|
|
63
|
+
1. **Window rules: match/swap** - match criteria and properties were swapped; now correctly separates `match:`-prefixed criteria from property rules
|
|
64
|
+
2. **Layer rules**: `blur=on = true` invalid Lua fixed; now emits `blur = true`
|
|
65
|
+
3. **Gestures**: nested inside `hl.config()` instead of `hl.gesture()` → now emitted as dedicated `hl.gesture({...})` calls
|
|
66
|
+
4. **Window move binds**: emitted raw tables instead of `hl.dsp.window.move()`; direction shorthand (`l`/`r`/`u`/`d`) expanded to `left`/`right`/`up`/`down`
|
|
67
|
+
5. **resizeactive binds**: now maps to `hl.dsp.window.resize({ x, y, relative = true })`
|
|
68
|
+
6. **Workspace-restore `+0`**: `+0` mapped to `workspace = "+0"` instead of `direction = "+0"`
|
|
69
|
+
7. **layoutmsg with trailing comment**: `layoutmsg, # dwindle` no longer parses argument as `nil`; flagged for manual review instead of crashing
|
|
70
|
+
|
|
71
|
+
### #38 - Windowrule/Layerrule Multi-word Values
|
|
72
|
+
- `workspace = "3 silent"` stays as string (not split into array)
|
|
73
|
+
- `size = 700 600`, `move 100%-433 53`, `opacity 0.9 0.8` → arrays `{700, 600}`, `{100%-433, 53}`, `{0.9, 0.8}`
|
|
74
|
+
|
|
75
|
+
### #39 - Animations Inside Sections
|
|
76
|
+
- `animation =`, `bezier =` directives inside `animations {}` now translate to `hl.animation()`/`hl.curve()` statements
|
|
77
|
+
- on/off flag → `enabled = true/false`
|
|
78
|
+
- styles like `popin 87%` preserved as `style = "popin 87%"`
|
|
79
|
+
- Statements emitted **outside** the `hl.config({})` table (valid Lua)
|
|
80
|
+
|
|
81
|
+
### #40 - Stdin Hyphen Whitespace
|
|
82
|
+
- `grim -c -g "$(slurp)" - | satty --filename -` preserves spaces around `-` and `|`
|
|
83
|
+
- Before: `grim -c -g \"$(slurp)\"-| satty --filename-` (spaces stripped)
|
|
84
|
+
|
|
85
|
+
### #33 - Comma in Variable Values
|
|
86
|
+
- `$kbNextWs = Ctrl+Super, right` parses correctly → `local kbNextWs = "Ctrl+Super, right"`
|
|
87
|
+
- Before: `kbNextWs = { }` (empty table)
|
|
88
|
+
|
|
89
|
+
### #32 - rgba() Color Parsing
|
|
90
|
+
- `shadow:color = rgba(0,0,0,0.85)` parses correctly
|
|
91
|
+
- Colon-paths expand to nested tables: `shadow = { color = "rgba(0,0,0,0.85)" }`
|
|
92
|
+
|
|
93
|
+
### #42 - movecurrentworkspacetomonitor Dispatcher
|
|
94
|
+
- New dispatcher: `hl.dsp.workspace.move({ monitor = "l" })`
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Test Results
|
|
99
|
+
|
|
100
|
+
- **106 tests passing** (only pre-existing `test_cli_help` fails due to module not being installed in /usr/bin/python path)
|
|
101
|
+
- All fixes verified against real-world hyprland configs
|
|
102
|
+
- Regressions: 0 (all existing tests continue to pass)
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## How to Build & Test
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# From project root
|
|
110
|
+
python -m build # Build sdist + wheel
|
|
111
|
+
python -m pytest tests/ # Run all 106 tests
|
|
112
|
+
python -m hyprconf2lua # CLI help
|
|
113
|
+
|
|
114
|
+
# Example conversions
|
|
115
|
+
hyprconf2lua example/hyprland.conf
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Guidelines for AI Agents Working on This Project
|
|
121
|
+
|
|
122
|
+
### Code Style
|
|
123
|
+
- Follow existing patterns in `src/hyprconf2lua/`
|
|
124
|
+
- Use `no_space_before` / `no_space_after` sets in `_join_tokens` for consistent spacing
|
|
125
|
+
- Keep `MULTI_VALUE_EFFECT_KEYS = {"move", "size", "opacity", "alpha"}` for multi-word effect values
|
|
126
|
+
- Dispatcher maps in `mappings.py` - add new dispatchers there
|
|
127
|
+
|
|
128
|
+
### Adding New Dispatchers
|
|
129
|
+
1. Add to `DISPATCHER_MAP` in `mappings.py` with `(func_string, needs_args)`
|
|
130
|
+
2. Handle in `build_dispatcher()` and `build_dispatcher_args()` in `codegen.py`
|
|
131
|
+
3. Add special cases for known patterns (e.g., `+0` → workspace, `l/r/u/d` → directions)
|
|
132
|
+
|
|
133
|
+
### Adding New Rule Types
|
|
134
|
+
1. Add to `WINDOW_RULE_MAP` or `LAYER_RULE_MAP` in `mappings.py`
|
|
135
|
+
2. Handle in `visit_windowrule()` / `visit_layerrule()` in `codegen.py`
|
|
136
|
+
3. Support both old-style (`rule, match:X`) and new-style (`match:key X`) syntax
|
|
137
|
+
|
|
138
|
+
### Adding New Animations/Beziers
|
|
139
|
+
1. Add `enabled` field to `AnimationDirective` in `ast.py`
|
|
140
|
+
2. Update `parse_animation()` in `parser.py` to extract `enabled`, `style` from comma values
|
|
141
|
+
3. Update `visit_animation()` in `codegen.py` to use `stmt.enabled` and `stmt.style`
|
|
142
|
+
4. Ensure statements are emitted **outside** `hl.config({})` table (see `emit_section_config`)
|
|
143
|
+
|
|
144
|
+
### Testing
|
|
145
|
+
- Run `python -m pytest tests/` to verify all 106 tests pass
|
|
146
|
+
- Add regression tests in `tests/test_converter.py` for new fixes
|
|
147
|
+
- Test with real hyprland configs via `hyprctl configerrors`
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Recent Changes History
|
|
152
|
+
|
|
153
|
+
| Version | Date | Key Fixes |
|
|
154
|
+
|---------|------|-----------|
|
|
155
|
+
| **1.7.0** | 2026-08-24 | All 7 bugs from #35, #38, #39, #40, #33, #32 fixed |
|
|
156
|
+
| **1.6.0** | 2026-08-20 | #26-#29 (source path, hyphens, ${} syntax, multiline exec) |
|
|
157
|
+
| **1.5.0** | 2026-08-28 | #24/#25 (hyphen→underscore, $HOME→os.getenv) |
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Contact & Support
|
|
162
|
+
|
|
163
|
+
- **GitHub:** https://github.com/Prateek-squadron/hyprconf2lua
|
|
164
|
+
- **PyPI:** https://pypi.org/project/hyprconf2lua/
|
|
165
|
+
- **Issues:** Use GitHub Issues for bug reports and feature requests
|
|
166
|
+
- **IRC/Slack:** #hyprland on Libera.Chat (project maintainer)
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
*This knowledge base was created for the v1.7.0 release cycle. For the latest updates, check the GitHub repository.*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.8.1"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
+
import json
|
|
2
3
|
import os
|
|
3
4
|
import re
|
|
4
5
|
from typing import Dict, List, Optional
|
|
@@ -54,7 +55,8 @@ class Codegen:
|
|
|
54
55
|
|
|
55
56
|
def generate(self, config: ConfigFile) -> str:
|
|
56
57
|
self.lines = []
|
|
57
|
-
|
|
58
|
+
import hyprconf2lua
|
|
59
|
+
self.emit(f"-- Generated by hyprconf2lua v{hyprconf2lua.__version__}")
|
|
58
60
|
self.emit("-- https://github.com/Prateek-squadron/hyprconf2lua")
|
|
59
61
|
self.emit("-- Manual review may be needed for complex directives")
|
|
60
62
|
self.emit("")
|
|
@@ -179,6 +181,9 @@ class Codegen:
|
|
|
179
181
|
return key.replace("-", "_")
|
|
180
182
|
|
|
181
183
|
def to_lua_val(self, val: str):
|
|
184
|
+
val = val.strip()
|
|
185
|
+
if val.endswith(";"):
|
|
186
|
+
val = val[:-1].strip()
|
|
182
187
|
val = self.resolve_val_with_env(val)
|
|
183
188
|
if val.startswith("local_var_"):
|
|
184
189
|
return val[len("local_var_"):]
|
|
@@ -305,8 +310,12 @@ class Codegen:
|
|
|
305
310
|
self.emit(f"{key} = {val},")
|
|
306
311
|
else:
|
|
307
312
|
self.translated_count += 1
|
|
308
|
-
|
|
309
|
-
|
|
313
|
+
if key == "kb_options":
|
|
314
|
+
val_str = ",".join(values)
|
|
315
|
+
self.emit(f"{key} = {self.quote(val_str)},")
|
|
316
|
+
else:
|
|
317
|
+
vals = [self.to_lua_val(v) for v in values]
|
|
318
|
+
self.emit(f"{key} = {{ {', '.join(vals)} }},")
|
|
310
319
|
|
|
311
320
|
def _group_section_body(self, directives: List[BlockStmt]) -> List[BlockStmt]:
|
|
312
321
|
grouped: List[BlockStmt] = []
|
|
@@ -384,8 +393,11 @@ class Codegen:
|
|
|
384
393
|
val = self.to_lua_val(d.value[0])
|
|
385
394
|
self.emit(f"{key} = {val},")
|
|
386
395
|
else:
|
|
387
|
-
|
|
388
|
-
|
|
396
|
+
if key == "kb_options":
|
|
397
|
+
self.emit(f"{key} = {self.quote(','.join(d.value))},")
|
|
398
|
+
else:
|
|
399
|
+
vals = [self.to_lua_val(v) for v in d.value]
|
|
400
|
+
self.emit(f"{key} = {{ {', '.join(vals)} }},")
|
|
389
401
|
self.dedent()
|
|
390
402
|
self.emit("},")
|
|
391
403
|
|
|
@@ -408,8 +420,11 @@ class Codegen:
|
|
|
408
420
|
v = self.to_lua_val(sd.value[0])
|
|
409
421
|
self.emit(f"{k} = {v},")
|
|
410
422
|
else:
|
|
411
|
-
|
|
412
|
-
|
|
423
|
+
if k == "kb_options":
|
|
424
|
+
self.emit(f"{k} = {self.quote(','.join(sd.value))},")
|
|
425
|
+
else:
|
|
426
|
+
vals = [self.to_lua_val(v) for v in sd.value]
|
|
427
|
+
self.emit(f"{k} = {{ {', '.join(vals)} }},")
|
|
413
428
|
self.dedent()
|
|
414
429
|
self.emit("end)")
|
|
415
430
|
elif isinstance(child, Directive):
|
|
@@ -504,10 +519,9 @@ class Codegen:
|
|
|
504
519
|
|
|
505
520
|
if dsp_code is None:
|
|
506
521
|
self.flag_count += 1
|
|
507
|
-
mods_str = " + ".join(stmt.mods) if stmt.mods else ""
|
|
508
522
|
self.emit(f'-- TODO: manual review (unknown dispatcher: {stmt.dispatcher})')
|
|
509
523
|
pstr = ", ".join(self.quote(self.resolve_val(p)) for p in stmt.params)
|
|
510
|
-
self.emit(f'-- hl.bind(
|
|
524
|
+
self.emit(f'-- hl.bind({combo_expr}, hl.dsp.{stmt.dispatcher}({pstr}))')
|
|
511
525
|
return
|
|
512
526
|
|
|
513
527
|
opt_parts = []
|
|
@@ -538,7 +552,7 @@ class Codegen:
|
|
|
538
552
|
if var_name in self.variables:
|
|
539
553
|
parts.append(var_name)
|
|
540
554
|
else:
|
|
541
|
-
parts.append(
|
|
555
|
+
parts.append("local_var_" + var_name)
|
|
542
556
|
else:
|
|
543
557
|
parts.append(self.quote(m))
|
|
544
558
|
|
|
@@ -547,6 +561,10 @@ class Codegen:
|
|
|
547
561
|
|
|
548
562
|
has_var = any(not p.startswith('"') for p in parts)
|
|
549
563
|
|
|
564
|
+
if not has_var and not is_key_var:
|
|
565
|
+
all_str = " + ".join(p.strip('"') for p in parts)
|
|
566
|
+
return self.quote(all_str + " + " + key_str.strip('"'))
|
|
567
|
+
|
|
550
568
|
if not has_var:
|
|
551
569
|
all_str = " + ".join(p.strip('"') for p in parts)
|
|
552
570
|
return self.quote(all_str) + ' .. " + " .. ' + key_str
|
|
@@ -582,7 +600,10 @@ class Codegen:
|
|
|
582
600
|
|
|
583
601
|
if dispatcher == "movetoworkspacesilent":
|
|
584
602
|
args = self.build_dispatcher_args(params, needs_args, func)
|
|
585
|
-
|
|
603
|
+
# Combine workspace dict with follow flag into single dict
|
|
604
|
+
if args and args.endswith("}"):
|
|
605
|
+
args = args.rstrip("}") + ", follow = false}"
|
|
606
|
+
return f'{func}({args})'
|
|
586
607
|
|
|
587
608
|
if dispatcher == "movefocus":
|
|
588
609
|
dir_map = {"l": "left", "r": "right", "u": "up", "d": "down"}
|
|
@@ -595,6 +616,22 @@ class Codegen:
|
|
|
595
616
|
return f'{func}({{ next = false }})'
|
|
596
617
|
return f'{func}()'
|
|
597
618
|
|
|
619
|
+
if dispatcher == "pass":
|
|
620
|
+
return f'{func}({{ window = {self.quote(params[0]) if params else "nil"} }})'
|
|
621
|
+
|
|
622
|
+
if dispatcher == "fullscreen":
|
|
623
|
+
if params and params[0] == "1":
|
|
624
|
+
return f'{func}({{ mode = 1 }})'
|
|
625
|
+
elif params and params[0] == "0":
|
|
626
|
+
return f'{func}()'
|
|
627
|
+
return f'{func}()'
|
|
628
|
+
|
|
629
|
+
if dispatcher == "splitratio":
|
|
630
|
+
nums = params[0].split() if params else []
|
|
631
|
+
x = nums[0] if len(nums) > 0 else "0"
|
|
632
|
+
y = nums[1] if len(nums) > 1 else "0"
|
|
633
|
+
return f'{func}({{ x = {x}, y = {y}, relative = true }})'
|
|
634
|
+
|
|
598
635
|
if dispatcher == "resizeactive":
|
|
599
636
|
nums = params[0].split() if params else []
|
|
600
637
|
x = nums[0] if len(nums) > 0 else "0"
|
|
@@ -647,7 +684,7 @@ class Codegen:
|
|
|
647
684
|
return self.build_focus_dispatcher(func, params)
|
|
648
685
|
|
|
649
686
|
if dispatcher == "focusurgentorlast":
|
|
650
|
-
return f'{func}({{
|
|
687
|
+
return f'{func}({{ urgent_or_last = true }})'
|
|
651
688
|
|
|
652
689
|
if dispatcher == "focuscurrentorlast":
|
|
653
690
|
return f'{func}({{ last = true }})'
|
|
@@ -817,6 +854,7 @@ class Codegen:
|
|
|
817
854
|
self.indent()
|
|
818
855
|
|
|
819
856
|
name_str = re.sub(r'[^a-zA-Z0-9_-]', '_', name_source[:20].lower())
|
|
857
|
+
name_str = f"{name_str}_{stmt.line}"
|
|
820
858
|
self.emit(f'name = "{name_str}",')
|
|
821
859
|
|
|
822
860
|
self.emit("match = {")
|
|
@@ -898,7 +936,7 @@ class Codegen:
|
|
|
898
936
|
if style and style != "default":
|
|
899
937
|
style_extra = f', style = {self.quote(style)}'
|
|
900
938
|
|
|
901
|
-
if curve
|
|
939
|
+
if curve:
|
|
902
940
|
if re.match(r'^\d+(\.\d+)?$', curve):
|
|
903
941
|
return self.emit(f"-- TODO: manual review (numeric curve ref in animation: {stmt.name})")
|
|
904
942
|
|
|
@@ -14,7 +14,7 @@ TOKEN_SPECS = [
|
|
|
14
14
|
("COLON", r":"),
|
|
15
15
|
("SHELL_EXP", r"\$\{[^}\n]*\}"),
|
|
16
16
|
("DOLLAR", r"\$"),
|
|
17
|
-
("STRING", r'"([^"\\]|\\.)*"'),
|
|
17
|
+
("STRING", r'"([^"\\]|\\.)*"|\'([^\'\\]|\\.)*\''),
|
|
18
18
|
("CONT", r"\\[ \t]*\n"),
|
|
19
19
|
("IDENT", r'[^\s#"={},:!]+'),
|
|
20
20
|
("NEWLINE", r"\n"),
|
|
@@ -71,7 +71,7 @@ def tokenize(source: str) -> List[Token]:
|
|
|
71
71
|
elif kind == "MISMATCH":
|
|
72
72
|
raise LexerError(f"Unexpected character: {value!r}", line, _col(pos))
|
|
73
73
|
elif kind == "STRING":
|
|
74
|
-
tokens.append(Token("STRING", value
|
|
74
|
+
tokens.append(Token("STRING", value, line, _col(pos)))
|
|
75
75
|
else:
|
|
76
76
|
tokens.append(Token(kind, value, line, _col(pos)))
|
|
77
77
|
|
|
@@ -58,10 +58,10 @@ DISPATCHER_MAP = {
|
|
|
58
58
|
|
|
59
59
|
BIND_FLAGS_TO_OPTIONS = {
|
|
60
60
|
"l": ("locked", "true"),
|
|
61
|
-
"r": ("
|
|
61
|
+
"r": ("release", "true"),
|
|
62
62
|
"n": ("non_consuming", "true"),
|
|
63
63
|
"m": ("mouse", "true"),
|
|
64
|
-
"e": ("
|
|
64
|
+
"e": ("repeating", "true"),
|
|
65
65
|
"t": ("transparent", "true"),
|
|
66
66
|
"i": ("ignore_mods", "true"),
|
|
67
67
|
"p": ("pass", "true"),
|
|
@@ -97,6 +97,8 @@ WINDOW_RULE_PARAM_MAP = {
|
|
|
97
97
|
"minsize": ("min_size", True),
|
|
98
98
|
"maxsize": ("max_size", True),
|
|
99
99
|
"idleinhibit": ("idle_inhibit", True),
|
|
100
|
+
"stay_focused": ("stay_focused", True),
|
|
101
|
+
"dim_around": ("dim_around", True),
|
|
100
102
|
"xray": ("xray", True),
|
|
101
103
|
"center": ("center", True),
|
|
102
104
|
"keepaspectratio": ("keep_aspect_ratio", "true"),
|
|
@@ -112,7 +114,7 @@ WINDOW_RULE_PARAM_MAP = {
|
|
|
112
114
|
|
|
113
115
|
WORKSPACE_RULE_MAP = {
|
|
114
116
|
"monitor": "monitor",
|
|
115
|
-
"default": "
|
|
117
|
+
"default": "default",
|
|
116
118
|
"gapsin": "gaps_in",
|
|
117
119
|
"gapsout": "gaps_out",
|
|
118
120
|
"bordersize": "border_size",
|
|
@@ -15,7 +15,7 @@ BIND_FLAG_MAP = {
|
|
|
15
15
|
"bindn": "n",
|
|
16
16
|
"bindo": "",
|
|
17
17
|
"bindm": "m",
|
|
18
|
-
"binde": "",
|
|
18
|
+
"binde": "e",
|
|
19
19
|
"bindt": "t",
|
|
20
20
|
"bindi": "i",
|
|
21
21
|
"bindp": "p",
|
|
@@ -212,8 +212,8 @@ class Parser:
|
|
|
212
212
|
current.append("$" + var_t.value)
|
|
213
213
|
else:
|
|
214
214
|
t = self.advance()
|
|
215
|
-
if
|
|
216
|
-
current.append(
|
|
215
|
+
if t.type == "STRING" and not keep_string_quotes:
|
|
216
|
+
current.append(t.value[1:-1])
|
|
217
217
|
else:
|
|
218
218
|
current.append(t.value)
|
|
219
219
|
remaining = self._join_tokens(current)
|
|
@@ -445,8 +445,8 @@ class Parser:
|
|
|
445
445
|
parts.append("$" + var_t.value)
|
|
446
446
|
else:
|
|
447
447
|
t = self.advance()
|
|
448
|
-
if
|
|
449
|
-
parts.append(
|
|
448
|
+
if t.type == "STRING" and not keep_string_quotes:
|
|
449
|
+
parts.append(t.value[1:-1])
|
|
450
450
|
else:
|
|
451
451
|
parts.append(t.value)
|
|
452
452
|
return self._join_tokens(parts)
|