Add the shift_monitors plugin

This commit is contained in:
fdev31 2023-05-03 22:03:18 +02:00
parent 96d5f23ea5
commit 3d79041992
2 changed files with 34 additions and 0 deletions

View file

@ -0,0 +1,24 @@
from .interface import Plugin
from ..ipc import hyprctlJSON, hyprctl
class Extension(Plugin):
async def init(self):
self.monitors = [mon["name"] for mon in await hyprctlJSON("monitors")]
async def run_shift_monitors(self, arg: str):
direction: int = int(arg)
if direction > 0:
mon_list = self.monitors[:-1]
else:
mon_list = reversed(self.monitors[1:])
for i, mon in enumerate(mon_list):
await hyprctl(f"swapactiveworkspaces {mon} {self.monitors[i+direction]}")
async def event_monitoradded(self, monitor):
self.monitors.append(monitor.strip())
async def event_monitorremoved(self, monitor):
self.monitors.remove(monitor.strip())