Skip to content

Commit

Permalink
scratchpad: Improve user feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
fdev31 committed Nov 29, 2023
1 parent 3cf8d0b commit d91581f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Check the [Getting started](https://github.com/hyprland-community/pyprland/wiki/
> [!note]
> **WIP: current `main` branch**
> - `scratchpads`: experimental progressive web apps support
> - `scratchpads`: better feedback on usage errors
# 1.6.5

Expand Down
19 changes: 19 additions & 0 deletions pyprland/plugins/scratchpads.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,13 @@ async def run_toggle(self, uid_or_uids: str) -> None:

assert len(uids)
first_scratch = self.scratches.get(uids[0])
if not first_scratch:
self.log.warning("%s doesn't exist, can't toggle.", uids[0])
await notify_error(
f"Scratchpad '{uids[0]}' not found, check your configuration or the toggle parameter"
)
return

is_visible = (
first_scratch.visible
and first_scratch.space_identifier == get_space_identifier(self)
Expand Down Expand Up @@ -680,6 +687,13 @@ async def run_show(self, uid) -> None:
uid = uid.strip()
item = self.scratches.get(uid)

if not item:
self.log.warning("%s doesn't exist, can't hide.", uid)
await notify_error(
f"Scratchpad '{uid}' not found, check your configuration or the show parameter"
)
return

self.focused_window_tracking[uid] = cast(
dict[str, Any], await hyprctlJSON("activewindow")
)
Expand Down Expand Up @@ -763,10 +777,15 @@ async def run_hide(self, uid: str, force=False, autohide=False) -> None:
`force` ignores the visibility check"""
uid = uid.strip()
scratch = self.scratches.get(uid)

if not scratch:
await notify_error(
f"Scratchpad '{uid}' not found, check your configuration or the hide parameter"
)
self.log.warning("%s is not configured", uid)
return
if not scratch.visible and not force:
await notify_error(f"Scratchpad '{uid}' is not visible, will not hide.")
self.log.warning("%s is already hidden", uid)
return
scratch.visible = False
Expand Down

0 comments on commit d91581f

Please sign in to comment.