Add the shift_monitors plugin
This commit is contained in:
parent
96d5f23ea5
commit
3d79041992
2 changed files with 34 additions and 0 deletions
10
README.md
10
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 <direction>`: swaps every monitor in the given direction
|
||||
|
||||
# Plugin: `magnify`
|
||||
|
||||
### Command
|
||||
|
|
24
pyprland/plugins/shift_monitors.py
Normal file
24
pyprland/plugins/shift_monitors.py
Normal 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())
|
Loading…
Add table
Add a link
Reference in a new issue