Rework screen configuration to avoid offsets
This commit is contained in:
parent
c96f2c6777
commit
458d8c886b
1 changed files with 34 additions and 3 deletions
|
@ -5,6 +5,34 @@ import subprocess
|
|||
from ..ipc import hyprctlJSON
|
||||
|
||||
|
||||
def configure_monitors(monitors, screenid: str, x: int, y: int) -> None:
|
||||
x_offset = -x if x < 0 else 0
|
||||
y_offset = -y if y < 0 else 0
|
||||
|
||||
min_x = x
|
||||
min_y = y
|
||||
|
||||
command = ["wlr-randr"]
|
||||
other_monitors = [mon for mon in monitors if mon["name"] != screenid]
|
||||
for mon in other_monitors:
|
||||
min_x = min(min_x, mon["x"])
|
||||
min_y = min(min_y, mon["y"])
|
||||
x_offset = -min_x
|
||||
y_offset = -min_y
|
||||
for mon in other_monitors:
|
||||
command.extend(
|
||||
[
|
||||
"--output",
|
||||
mon["name"],
|
||||
"--pos",
|
||||
f"{mon['x']+x_offset},{mon['y']+y_offset}",
|
||||
]
|
||||
)
|
||||
|
||||
command.extend(["--output", screenid, "--pos", f"{x+x_offset},{y+y_offset}"])
|
||||
subprocess.call(command)
|
||||
|
||||
|
||||
class Extension(Plugin):
|
||||
async def event_monitoradded(self, screenid):
|
||||
screenid = screenid.strip()
|
||||
|
@ -40,6 +68,9 @@ class Extension(Plugin):
|
|||
else: # rightof
|
||||
x: int = ref["x"] + ref["width"]
|
||||
y: int = ref["y"]
|
||||
subprocess.call(
|
||||
["wlr-randr", "--output", screenid, "--pos", f"{x},{y}"]
|
||||
)
|
||||
|
||||
configure_monitors(monitors, screenid, x, y)
|
||||
return
|
||||
default_command = self.config.get("noplacement")
|
||||
if default_command:
|
||||
subprocess.call(default_command, shell=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue