Use multiple xrandr invocations

This commit is contained in:
Roberto Alsina 2020-02-06 18:39:09 -03:00
parent a13c3436ef
commit eb17909563
2 changed files with 9 additions and 7 deletions

View File

@ -158,9 +158,10 @@ class Window(QObject):
for mon in self.screen.monitors.values():
mon.item.update_visuals(mon)
def run(self, cli):
print(f"Running {cli}")
subprocess.check_call(shlex.split(cli))
def run(self, commands):
for i, cmd in enumerate(commands, 1):
print(f"Running {cmd} [{i}/{len(commands)}]")
subprocess.check_call(shlex.split(cmd))
def do_reset(self):
self.run(self.reset_screen.generate())

View File

@ -30,9 +30,10 @@ class Screen:
self.update_replica_of()
def generate(self):
"""Create a xrandr invocation to match this state."""
cli = ["xrandr"]
"""Create a list of xrandr invocations to match this state."""
results = []
for output, mon in self.monitors.items():
cli = ["xrandr"]
cli.append(f"--output {output}")
if not mon.enabled:
cli.append("--off")
@ -47,8 +48,8 @@ class Screen:
cli.append(f"--rotate {mon.orientation}")
if mon.primary:
cli.append("--primary")
return " ".join(cli)
results.append(" ".join(cli))
return results
def update_replica_of(self):
"""Decide which monitors are replicas of each other and