Skip to content

Commit

Permalink
experimental "inherit" option
Browse files Browse the repository at this point in the history
  • Loading branch information
fdev31 committed Sep 27, 2024
1 parent 8e26c25 commit d11186e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyprland/plugins/scratchpads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ async def die_in_piece(scratch: Scratch) -> None:
async def on_reload(self) -> None:
"""Config loader."""
# Create new scratches with fresh config items
scratches = {name: Scratch(name, options) for name, options in self.config.items()}
scratches = {name: Scratch(name, self.config) for name, options in self.config.items()}

scratches_to_spawn = set()
for name in scratches:
scratch = self.scratches.get(name)
if scratch: # if existing scratch exists, overrides the conf object
scratch.set_config(scratches[name].conf)
scratch.set_config(self.config)
else:
# else register it
self.scratches.register(scratches[name], name)
Expand Down
12 changes: 11 additions & 1 deletion pyprland/plugins/scratchpads/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@ def forced_monitor(self) -> str | None:
return cast(str, forced_monitor)
return None

def set_config(self, opts: dict[str, Any]) -> None:
def set_config(self, full_config: dict[str, Any]) -> None:
"""Apply constraints to the configuration."""
opts = full_config[self.uid].copy()
if "inherit" in opts:
inheritance = opts["inherit"]
if isinstance(inheritance, str):
inheritance = [inheritance]
for source in inheritance:
opts.update(full_config.get(source, {}))

opts.update(full_config[self.uid])

if "class_match" in opts: # NOTE: legacy, to be removed
opts["match_by"] = "class"
if self.cast_bool(opts.get("preserve_aspect")):
Expand Down
2 changes: 1 addition & 1 deletion pyprland/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Package version."""

VERSION = "2.4.0-52"
VERSION = "2.4.0-54"

0 comments on commit d11186e

Please sign in to comment.