add the expose plugin
This commit is contained in:
parent
d340ae00c7
commit
1ecfa3443c
2 changed files with 76 additions and 0 deletions
51
pyprland/plugins/expose.py
Normal file
51
pyprland/plugins/expose.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
from typing import Any
|
||||
from .interface import Plugin
|
||||
|
||||
from ..ipc import hyprctlJSON, hyprctl
|
||||
|
||||
|
||||
class Extension(Plugin):
|
||||
async def init(self) -> None:
|
||||
self.exposed = False
|
||||
|
||||
async def run_toggle_minimized(self, special_workspace="minimized"):
|
||||
"""[name] Toggles switching the focused window to the special workspace "name" (default: minimized)"""
|
||||
aw: dict[str, Any] = await hyprctlJSON("activewindow")
|
||||
wid = aw["workspace"]["id"]
|
||||
assert isinstance(wid, int)
|
||||
if wid < 1: # special workspace: unminimize
|
||||
wrk = await hyprctlJSON("activeworkspace")
|
||||
await hyprctl(f"togglespecialworkspace {special_workspace}")
|
||||
await hyprctl(f"movetoworkspacesilent {wrk['id']},address:{aw['address']}")
|
||||
await hyprctl(f"focuswindow address:{aw['address']}")
|
||||
else:
|
||||
await hyprctl(
|
||||
f"movetoworkspacesilent special:{special_workspace},address:{aw['address']}"
|
||||
)
|
||||
|
||||
@property
|
||||
def exposed_clients(self):
|
||||
if self.config.get("include_special", False):
|
||||
return self.exposed
|
||||
else:
|
||||
return [c for c in self.exposed if c["workspace"]["id"] > 0]
|
||||
|
||||
async def run_expose(self, arg=""):
|
||||
"""Expose every client on the active workspace. If expose is active restores everything and move to the focused window"""
|
||||
if self.exposed:
|
||||
aw: dict[str, Any] = await hyprctlJSON("activewindow")
|
||||
focused_addr = aw["address"]
|
||||
for client in self.exposed_clients:
|
||||
await hyprctl(
|
||||
f"movetoworkspacesilent {client['workspace']['id']},address:{client['address']}"
|
||||
)
|
||||
await hyprctl("togglespecialworkspace exposed")
|
||||
await hyprctl(f"focuswindow address:{focused_addr}")
|
||||
self.exposed = False
|
||||
else:
|
||||
self.exposed = await hyprctlJSON("clients")
|
||||
for client in self.exposed_clients:
|
||||
await hyprctl(
|
||||
f"movetoworkspacesilent special:exposed,address:{client['address']}"
|
||||
)
|
||||
await hyprctl("togglespecialworkspace exposed")
|
Loading…
Add table
Add a link
Reference in a new issue