diff --git a/pyprland/plugins/monitors.py b/pyprland/plugins/monitors.py index 06fce76..aaa18c5 100644 --- a/pyprland/plugins/monitors.py +++ b/pyprland/plugins/monitors.py @@ -1,5 +1,4 @@ " The monitors plugin " -import asyncio import subprocess from collections import defaultdict from copy import deepcopy @@ -105,7 +104,8 @@ class Extension(Plugin): # pylint: disable=missing-class-docstring async def load_config(self, config) -> None: await super().load_config(config) - await self.run_relayout() + if self.config.get("startup_relayout", True): + await self.run_relayout() # Command @@ -130,31 +130,27 @@ async def run_relayout( # Event handlers - async def event_monitoradded( - self, monitor_name, no_default=False, monitors: list | None = None - ) -> None: + async def event_monitoradded(self, monitor_name) -> None: "Triggers when a monitor is plugged" - if not monitors: - monitors = cast(list, await self.hyprctlJSON("monitors")) - - assert monitors - - for mon in monitors: - if mon["name"].startswith(monitor_name): - mon_info = mon - break + if self.config.get("full_relayout", False): + await self.run_relayout() else: - self.log.warning("Monitor %s not found", monitor_name) - return + if not monitors: + monitors = cast(list, await self.hyprctlJSON("monitors")) + + assert monitors - if self._place_single_monitor(mon_info, monitors): - return + for mon in monitors: + if mon["name"].startswith(monitor_name): + mon_info = mon + break + else: + self.log.warning("Monitor %s not found", monitor_name) + return - if not no_default: - default_command = self.config.get("unknown") - if default_command: - await asyncio.create_subprocess_shell(default_command) + if self._place_single_monitor(mon_info, monitors): + return # Utils diff --git a/tests/conftest.py b/tests/conftest.py index cd27558..ccadd93 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -47,7 +47,7 @@ def __init__(self): async def pypr(cmd): "Simulates the pypr command" assert pyprctrl_mock - return pyprctrl_mock.q.put(b"%s\n" % cmd.encode("utf-8")) + await pyprctrl_mock.q.put(b"%s\n" % cmd.encode("utf-8")) async def my_mocked_unix_server(reader, *a):