From 1d0f2610f8df386c4385bf5c57e6684173684d61 Mon Sep 17 00:00:00 2001 From: Adam Gausmann Date: Thu, 20 Mar 2025 10:24:47 -0500 Subject: [PATCH] Rename output.device -> port; wpaperd: use output port --- install.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/install.py b/install.py index 271ae29..88344a0 100755 --- a/install.py +++ b/install.py @@ -90,7 +90,7 @@ class OutputConfig: scale: float | None = None background_path: str | None = None background_mode: BackgroundMode = BackgroundMode.Fill - device: str | None = None + port: str | None = None @property def sway_lines(self) -> str: @@ -108,12 +108,12 @@ class OutputConfig: @property def swaylock_image_line(self) -> str | None: - if (self.match != "*" and self.device is None) or self.background_path is None: + if (self.match != "*" and self.port is None) or self.background_path is None: return None if self.match == "*": return f"image={self.background_path}" - return f"image={self.device}:{self.background_path}" + return f"image={self.port}:{self.background_path}" @property def niri_lines(self) -> str: @@ -132,8 +132,9 @@ class OutputConfig: if self.background_path is None: return {} - key = self.match - if key == "*": + # TODO: match by serial number instead of by port + key = self.port + if self.match == "*": key = "any" return { @@ -228,7 +229,7 @@ def main(): host_config = cattrs.structure(host_toml, HostConfig) for output in host_config.outputs: - # Attempt to resolve device names for swaylock template + # Attempt to resolve port names for swaylock template # (Workaround https://github.com/swaywm/swaylock/issues/114) # # This will only work if this is run on the target host @@ -242,9 +243,9 @@ def main(): ["swaymsg", "-t", "get_outputs", "-p"], ).decode("utf-8") for line in get_outputs.splitlines(): - # Line format: Output '' + # Line format: Output '' if line.startswith("Output") and output.match in line: - output.device = line.split()[1] + output.port = line.split()[1] break elif "NIRI_SOCKET" in os.environ: @@ -252,9 +253,9 @@ def main(): ["niri", "msg", "outputs"], ).decode("utf-8") for line in get_outputs.splitlines(): - # Line format: Output "" () + # Line format: Output "" () if line.startswith("Output") and output.match in line: - output.device = ( + output.port = ( line.split()[-1].removeprefix("(").removesuffix(")") ) break