scratchpads: add the "lazy" option (closes #5)

This commit is contained in:
fdev31 2023-07-12 19:59:17 +02:00
parent 7bcd11b36d
commit 647e8214d9
2 changed files with 9 additions and 3 deletions

View file

@ -320,12 +320,16 @@ number of pixels for the animation.
#### `unfocus` (optional) #### `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) #### `margin` (optional)
number of pixels separating the scratchpad from the screen border 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 # Changelog
- Add `expose` addon - Add `expose` addon

View file

@ -147,7 +147,8 @@ class Extension(Plugin):
# not known yet # not known yet
for name in new_scratches: 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: def start_scratch_command(self, name: str) -> None:
self._respawned_scratches.add(name) self._respawned_scratches.add(name)
@ -290,7 +291,8 @@ class Extension(Plugin):
if not item.isAlive(): if not item.isAlive():
print(f"{uid} is not running, restarting...") 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: if item.pid in self.scratches_by_pid:
del self.scratches_by_pid[item.pid] del self.scratches_by_pid[item.pid]
if item.address in self.scratches_by_address: if item.address in self.scratches_by_address: