diff --git a/README.md b/README.md index 4f1f8f5..a86e9d1 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ A single config file `~/.config/hypr/pyprland.json` is used, using the following - `lost_windows` brings lost floating windows to the current workspace - `toggle_dpms` toggles the DPMS status of every plugged monitor - `magnify` toggles zooming of viewport or sets a specific scaling factor +- `shift_monitors` adds a self-configured "swapactiveworkspaces" command ## Installation @@ -88,6 +89,15 @@ Create a configuration file in `~/.config/hypr/pyprland.json` enabling a list of } ``` +# Plugin: `shift_monitors` + +Swaps the workspaces of every screen in the given direction. +Note the behavior can be hard to predict if you have more than 2 monitors, suggestions are welcome. + +### Command + +- `shift_monitors `: swaps every monitor in the given direction + # Plugin: `magnify` ### Command diff --git a/pyprland/plugins/shift_monitors.py b/pyprland/plugins/shift_monitors.py new file mode 100644 index 0000000..caa179d --- /dev/null +++ b/pyprland/plugins/shift_monitors.py @@ -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())