Skip to content

Commit

Permalink
pinned scratchpads are the default (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
fdev31 committed Jun 24, 2024
1 parent 37b036a commit 3fa1771
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
13 changes: 13 additions & 0 deletions pyprland/plugins/scratchpads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ async def update_scratch_info(self, orig_scratch: Scratch | None = None) -> None
self.log.info("Didn't update scratch info %s", self)

# Events {{{
async def event_workspace(self, name: str) -> None:
"""Workspace hook."""
for scratch in self.scratches.values():
scratch.event_workspace(name)

self.workspace = name

async def event_closewindow(self, addr: str) -> None:
"""Close window hook."""
# removes this address from the extra_addr
Expand Down Expand Up @@ -615,6 +622,10 @@ async def _show_transition(self, scratch: Scratch, monitor: MonitorInfo, was_ali
relative_animation = preserve_aspect and was_alive and not should_set_aspect
await self._animate_show(scratch, monitor, relative_animation)
await self.hyprctl(f"focuswindow address:{scratch.full_address}")

if scratch.conf.get("pinned", True) and not scratch.client_info["pinned"]:
await self.hyprctl(f"pin address:{scratch.full_address}")

scratch.meta.last_shown = time.time()
scratch.meta.monitor_info = monitor

Expand Down Expand Up @@ -729,6 +740,8 @@ async def run_hide(self, uid: str, force: bool = False, autohide: bool = False)
self.log.info("Hiding %s", uid)
await self._hide_transition(scratch, monitor_info)

if scratch.conf.get("pinned", True):
await self.hyprctl(f"pin address:{scratch.full_address}")
await self.hyprctl(f"movetoworkspacesilent special:scratch_{uid},address:{scratch.full_address}")

for addr in scratch.extra_addr:
Expand Down
5 changes: 5 additions & 0 deletions pyprland/plugins/scratchpads/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ async def update_client_info(

self.client_info.update(client_info)

def event_workspace(self, name: str) -> None:
"""Check if the workspace changed."""
if self.conf.get("pinned", True):
self.meta.space_identifier = name, self.meta.space_identifier[1]

def __str__(self) -> str:
return f"{self.uid} {self.address} : {self.client_info} / {self.conf}"

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.3.8-2"
VERSION = "2.3.8-8"

0 comments on commit 3fa1771

Please sign in to comment.