hyprland-schema 0.1.0__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.
@@ -0,0 +1,8 @@
1
+ .idea/
2
+ __pycache__/
3
+ *.pyc
4
+ dist/
5
+ *.egg-info/
6
+ .venv/
7
+ .pytest_cache/
8
+ .python-version
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ivo Šmerek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,142 @@
1
+ Metadata-Version: 2.4
2
+ Name: hyprland-schema
3
+ Version: 0.1.0
4
+ Summary: Typed Python schema for every Hyprland configuration option
5
+ Project-URL: Repository, https://github.com/BlueManCZ/hyprland-schema
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Keywords: compositor,hyprland,schema,wayland
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Topic :: Desktop Environment
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.12
19
+ Description-Content-Type: text/markdown
20
+
21
+ # hyprland-schema
22
+
23
+ Typed Python schema for every Hyprland configuration option — with defaults,
24
+ ranges, and descriptions. Generated from Hyprland's
25
+ [ConfigDescriptions.hpp](https://github.com/hyprwm/Hyprland/blob/main/src/config/ConfigDescriptions.hpp).
26
+ Zero runtime dependencies — stdlib only.
27
+
28
+ ## Installation
29
+
30
+ ```
31
+ pip install hyprland-schema
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ ```python
37
+ import hyprland_schema
38
+
39
+ # Schema version
40
+ print(hyprland_schema.HYPRLAND_VERSION) # "v0.54.2"
41
+
42
+ # Lookup by key
43
+ border = hyprland_schema.OPTIONS_BY_KEY["general:border_size"]
44
+ print(border.type, border.default, border.min, border.max)
45
+ # int 1 0 20
46
+
47
+ # Filter by section
48
+ for opt in hyprland_schema.get_section("general"):
49
+ print(f"{opt.name}: {opt.type} = {opt.default}")
50
+
51
+ # Filter by subsection
52
+ for opt in hyprland_schema.get_subsection("decoration", "blur"):
53
+ print(f"{opt.name}: {opt.type} = {opt.default}")
54
+
55
+ # Iterate all options
56
+ for opt in hyprland_schema.OPTIONS:
57
+ print(f"{opt.key}: {opt.type}")
58
+
59
+ # Export as JSON
60
+ json_str = hyprland_schema.get_json()
61
+ ```
62
+
63
+ ### Loading older Hyprland versions
64
+
65
+ ```python
66
+ import hyprland_schema
67
+
68
+ # List all bundled versions (newest first)
69
+ print(hyprland_schema.available_versions())
70
+
71
+ # Load schema for a specific version
72
+ schema = hyprland_schema.load("v0.54.2")
73
+ print(schema.version, len(schema.options))
74
+
75
+ # Schema objects have the same filtering API
76
+ for opt in schema.get_section("general"):
77
+ print(f"{opt.name}: {opt.type} = {opt.default}")
78
+
79
+ # Lookup on a Schema
80
+ border = schema.options_by_key["general:border_size"]
81
+ ```
82
+
83
+ Resolution order for `load()`:
84
+
85
+ 1. **Latest bundled version** — instant (pre-parsed).
86
+ 2. **Older bundled version** — reconstructed via reverse migrations.
87
+ 3. **Disk cache** at `~/.cache/hyprland-schema/` — no network needed.
88
+ 4. **GitHub fetch** — downloads `ConfigDescriptions.hpp` and parses it.
89
+
90
+ ## API
91
+
92
+ | Symbol | Type / Signature | Description |
93
+ |--------------------------|----------------------------------|---------------------------------------------|
94
+ | `HYPRLAND_VERSION` | `str` | Hyprland tag the schema was built from |
95
+ | `OPTIONS` | `tuple[HyprOption, ...]` | All configuration options |
96
+ | `OPTIONS_BY_KEY` | `dict[str, HyprOption]` | Lookup by dotted key |
97
+ | `get_section(s)` | `(str) -> list[HyprOption]` | Options in a top-level section |
98
+ | `get_subsection(s, sub)` | `(str, str) -> list[HyprOption]` | Options in a nested subsection |
99
+ | `get_json()` | `(*, indent=2) -> str` | Full schema as a JSON string |
100
+ | `load(version)` | `(str) -> Schema` | Load schema for a specific Hyprland version |
101
+ | `available_versions()` | `() -> list[str]` | All bundled versions, newest first |
102
+
103
+ ### Schema
104
+
105
+ `Schema` is a frozen dataclass returned by `load()`. It holds options for a
106
+ specific Hyprland version.
107
+
108
+ | Attribute / Method | Type / Signature | Description |
109
+ |--------------------------|----------------------------------|--------------------------------|
110
+ | `version` | `str` | Hyprland version tag |
111
+ | `options` | `tuple[HyprOption, ...]` | All options for this version |
112
+ | `options_by_key` | `dict[str, HyprOption]` | Lookup by dotted key |
113
+ | `get_section(s)` | `(str) -> list[HyprOption]` | Options in a top-level section |
114
+ | `get_subsection(s, sub)` | `(str, str) -> list[HyprOption]` | Options in a nested subsection |
115
+ | `get_json()` | `(*, indent=2) -> str` | Schema as a JSON string |
116
+
117
+ ## HyprOption fields
118
+
119
+ | Field | Type | Description |
120
+ |---------------|-----------------------------|-------------------------------------------------------------------------|
121
+ | `key` | `str` | `"general:border_size"` |
122
+ | `section` | `tuple[str, ...]` | `("general",)` |
123
+ | `name` | `str` | `"border_size"` |
124
+ | `description` | `str` | Human-readable text |
125
+ | `type` | `str` | `bool`, `int`, `float`, `string`, `color`, `gradient`, `vec2`, `choice` |
126
+ | `default` | `Any` | Default value |
127
+ | `min` | `int \| float \| None` | For `int`/`float` types |
128
+ | `max` | `int \| float \| None` | For `int`/`float` types |
129
+ | `enum_values` | `tuple[str, ...] \| None` | For `choice` type |
130
+ | `default_str` | `str \| None` | Human-readable default for `choice` type |
131
+ | `default_min` | `tuple[float, ...] \| None` | For `vec2` type |
132
+ | `default_max` | `tuple[float, ...] \| None` | For `vec2` type |
133
+
134
+
135
+
136
+ ## Requirements
137
+
138
+ - Python >= 3.12
139
+
140
+ ## License
141
+
142
+ MIT
@@ -0,0 +1,122 @@
1
+ # hyprland-schema
2
+
3
+ Typed Python schema for every Hyprland configuration option — with defaults,
4
+ ranges, and descriptions. Generated from Hyprland's
5
+ [ConfigDescriptions.hpp](https://github.com/hyprwm/Hyprland/blob/main/src/config/ConfigDescriptions.hpp).
6
+ Zero runtime dependencies — stdlib only.
7
+
8
+ ## Installation
9
+
10
+ ```
11
+ pip install hyprland-schema
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```python
17
+ import hyprland_schema
18
+
19
+ # Schema version
20
+ print(hyprland_schema.HYPRLAND_VERSION) # "v0.54.2"
21
+
22
+ # Lookup by key
23
+ border = hyprland_schema.OPTIONS_BY_KEY["general:border_size"]
24
+ print(border.type, border.default, border.min, border.max)
25
+ # int 1 0 20
26
+
27
+ # Filter by section
28
+ for opt in hyprland_schema.get_section("general"):
29
+ print(f"{opt.name}: {opt.type} = {opt.default}")
30
+
31
+ # Filter by subsection
32
+ for opt in hyprland_schema.get_subsection("decoration", "blur"):
33
+ print(f"{opt.name}: {opt.type} = {opt.default}")
34
+
35
+ # Iterate all options
36
+ for opt in hyprland_schema.OPTIONS:
37
+ print(f"{opt.key}: {opt.type}")
38
+
39
+ # Export as JSON
40
+ json_str = hyprland_schema.get_json()
41
+ ```
42
+
43
+ ### Loading older Hyprland versions
44
+
45
+ ```python
46
+ import hyprland_schema
47
+
48
+ # List all bundled versions (newest first)
49
+ print(hyprland_schema.available_versions())
50
+
51
+ # Load schema for a specific version
52
+ schema = hyprland_schema.load("v0.54.2")
53
+ print(schema.version, len(schema.options))
54
+
55
+ # Schema objects have the same filtering API
56
+ for opt in schema.get_section("general"):
57
+ print(f"{opt.name}: {opt.type} = {opt.default}")
58
+
59
+ # Lookup on a Schema
60
+ border = schema.options_by_key["general:border_size"]
61
+ ```
62
+
63
+ Resolution order for `load()`:
64
+
65
+ 1. **Latest bundled version** — instant (pre-parsed).
66
+ 2. **Older bundled version** — reconstructed via reverse migrations.
67
+ 3. **Disk cache** at `~/.cache/hyprland-schema/` — no network needed.
68
+ 4. **GitHub fetch** — downloads `ConfigDescriptions.hpp` and parses it.
69
+
70
+ ## API
71
+
72
+ | Symbol | Type / Signature | Description |
73
+ |--------------------------|----------------------------------|---------------------------------------------|
74
+ | `HYPRLAND_VERSION` | `str` | Hyprland tag the schema was built from |
75
+ | `OPTIONS` | `tuple[HyprOption, ...]` | All configuration options |
76
+ | `OPTIONS_BY_KEY` | `dict[str, HyprOption]` | Lookup by dotted key |
77
+ | `get_section(s)` | `(str) -> list[HyprOption]` | Options in a top-level section |
78
+ | `get_subsection(s, sub)` | `(str, str) -> list[HyprOption]` | Options in a nested subsection |
79
+ | `get_json()` | `(*, indent=2) -> str` | Full schema as a JSON string |
80
+ | `load(version)` | `(str) -> Schema` | Load schema for a specific Hyprland version |
81
+ | `available_versions()` | `() -> list[str]` | All bundled versions, newest first |
82
+
83
+ ### Schema
84
+
85
+ `Schema` is a frozen dataclass returned by `load()`. It holds options for a
86
+ specific Hyprland version.
87
+
88
+ | Attribute / Method | Type / Signature | Description |
89
+ |--------------------------|----------------------------------|--------------------------------|
90
+ | `version` | `str` | Hyprland version tag |
91
+ | `options` | `tuple[HyprOption, ...]` | All options for this version |
92
+ | `options_by_key` | `dict[str, HyprOption]` | Lookup by dotted key |
93
+ | `get_section(s)` | `(str) -> list[HyprOption]` | Options in a top-level section |
94
+ | `get_subsection(s, sub)` | `(str, str) -> list[HyprOption]` | Options in a nested subsection |
95
+ | `get_json()` | `(*, indent=2) -> str` | Schema as a JSON string |
96
+
97
+ ## HyprOption fields
98
+
99
+ | Field | Type | Description |
100
+ |---------------|-----------------------------|-------------------------------------------------------------------------|
101
+ | `key` | `str` | `"general:border_size"` |
102
+ | `section` | `tuple[str, ...]` | `("general",)` |
103
+ | `name` | `str` | `"border_size"` |
104
+ | `description` | `str` | Human-readable text |
105
+ | `type` | `str` | `bool`, `int`, `float`, `string`, `color`, `gradient`, `vec2`, `choice` |
106
+ | `default` | `Any` | Default value |
107
+ | `min` | `int \| float \| None` | For `int`/`float` types |
108
+ | `max` | `int \| float \| None` | For `int`/`float` types |
109
+ | `enum_values` | `tuple[str, ...] \| None` | For `choice` type |
110
+ | `default_str` | `str \| None` | Human-readable default for `choice` type |
111
+ | `default_min` | `tuple[float, ...] \| None` | For `vec2` type |
112
+ | `default_max` | `tuple[float, ...] \| None` | For `vec2` type |
113
+
114
+
115
+
116
+ ## Requirements
117
+
118
+ - Python >= 3.12
119
+
120
+ ## License
121
+
122
+ MIT
@@ -0,0 +1,42 @@
1
+ [project]
2
+ name = "hyprland-schema"
3
+ version = "0.1.0"
4
+ description = "Typed Python schema for every Hyprland configuration option"
5
+ requires-python = ">=3.12"
6
+ license = "MIT"
7
+ readme = "README.md"
8
+ keywords = ["hyprland", "schema", "wayland", "compositor"]
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "License :: OSI Approved :: MIT License",
12
+ "Operating System :: POSIX :: Linux",
13
+ "Programming Language :: Python :: 3.12",
14
+ "Programming Language :: Python :: 3.13",
15
+ "Intended Audience :: Developers",
16
+ "Topic :: Desktop Environment",
17
+ "Topic :: Software Development :: Libraries",
18
+ "Typing :: Typed",
19
+ ]
20
+
21
+ [project.urls]
22
+ Repository = "https://github.com/BlueManCZ/hyprland-schema"
23
+
24
+ [dependency-groups]
25
+ dev = ["pyright>=1.1", "pytest>=9.0", "ruff>=0.15"]
26
+
27
+ [build-system]
28
+ requires = ["hatchling"]
29
+ build-backend = "hatchling.build"
30
+
31
+ [tool.hatch.build]
32
+ only-packages = true
33
+
34
+ [tool.hatch.build.targets.sdist]
35
+ exclude = ["tests/"]
36
+
37
+ [tool.ruff]
38
+ target-version = "py312"
39
+ line-length = 100
40
+
41
+ [tool.ruff.lint]
42
+ select = ["E", "F", "W", "I"]
@@ -0,0 +1,73 @@
1
+ """Hyprland configuration option schema."""
2
+
3
+ import functools
4
+ from types import MappingProxyType
5
+
6
+ from hyprland_schema._data import HYPRLAND_VERSION as HYPRLAND_VERSION
7
+ from hyprland_schema._data import OPTIONS as OPTIONS
8
+ from hyprland_schema._model import HyprOption as HyprOption
9
+ from hyprland_schema._schema import Schema as Schema
10
+
11
+ __all__ = [
12
+ "HYPRLAND_VERSION",
13
+ "HyprOption",
14
+ "OPTIONS",
15
+ "OPTIONS_BY_KEY",
16
+ "Schema",
17
+ "available_versions",
18
+ "get_json",
19
+ "get_section",
20
+ "get_subsection",
21
+ "load",
22
+ ]
23
+
24
+
25
+ @functools.cache
26
+ def _get_latest_schema() -> Schema:
27
+ return Schema(version=HYPRLAND_VERSION, options=OPTIONS)
28
+
29
+
30
+ OPTIONS_BY_KEY: MappingProxyType[str, HyprOption] = _get_latest_schema().options_by_key
31
+
32
+
33
+ def get_section(section: str) -> list[HyprOption]:
34
+ """Return all options whose top-level section matches."""
35
+ return _get_latest_schema().get_section(section)
36
+
37
+
38
+ def get_subsection(section: str, subsection: str) -> list[HyprOption]:
39
+ """Return all options in a nested subsection."""
40
+ return _get_latest_schema().get_subsection(section, subsection)
41
+
42
+
43
+ def get_json(*, indent: int | None = 2) -> str:
44
+ """Return the full schema as a JSON string.
45
+
46
+ Produces the same format as the schema.json that the generator emits.
47
+ """
48
+ return _get_latest_schema().get_json(indent=indent)
49
+
50
+
51
+ @functools.lru_cache(maxsize=32)
52
+ def load(version: str) -> Schema:
53
+ """Load the schema for a specific Hyprland version.
54
+
55
+ Resolution order:
56
+ 1. Latest bundled version — instant (pre-parsed).
57
+ 2. Older bundled version — reconstructed via reverse migrations.
58
+ 3. Disk cache at ~/.cache/hyprland-schema/ — no network needed.
59
+ 4. Download from GitHub — fetches ConfigDescriptions.hpp and parses it.
60
+
61
+ Results are cached in memory for repeated calls.
62
+ """
63
+ from hyprland_schema._migration import build_options
64
+
65
+ opts = build_options(version)
66
+ return Schema(version=version, options=opts)
67
+
68
+
69
+ def available_versions() -> list[str]:
70
+ """Return all bundled Hyprland versions, newest first."""
71
+ from hyprland_schema._migrations._registry import VERSIONS
72
+
73
+ return list(VERSIONS)