From 647e8214d92753af1515a9ff99018cdf9d88b021 Mon Sep 17 00:00:00 2001 From: fdev31 Date: Wed, 12 Jul 2023 19:59:17 +0200 Subject: [PATCH] scratchpads: add the "lazy" option (closes #5) --- README.md | 6 +++++- pyprland/plugins/scratchpads.py | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e0cfce8..28f69b4 100644 --- a/README.md +++ b/README.md @@ -320,12 +320,16 @@ number of pixels for the animation. #### `unfocus` (optional) -allow to hide the window when the focus is lost when set to "hide" +when set to `true`, allow to hide the window when the focus is lost when set to "hide" #### `margin` (optional) number of pixels separating the scratchpad from the screen border +#### `lazy` (optional) + +when set to `true`, prevents the command from being started when pypr starts, it will be started when the scratchpad is first used instead. + # Changelog - Add `expose` addon diff --git a/pyprland/plugins/scratchpads.py b/pyprland/plugins/scratchpads.py index ed95b29..10418a9 100644 --- a/pyprland/plugins/scratchpads.py +++ b/pyprland/plugins/scratchpads.py @@ -147,7 +147,8 @@ class Extension(Plugin): # not known yet for name in new_scratches: - self.start_scratch_command(name) + if not self.scratches[name].conf.get("lazy", False): + self.start_scratch_command(name) def start_scratch_command(self, name: str) -> None: self._respawned_scratches.add(name) @@ -290,7 +291,8 @@ class Extension(Plugin): if not item.isAlive(): print(f"{uid} is not running, restarting...") - self.procs[uid].kill() + if uid in self.procs: + self.procs[uid].kill() if item.pid in self.scratches_by_pid: del self.scratches_by_pid[item.pid] if item.address in self.scratches_by_address: