mirror of
https://github.com/gryf/pyrandr.git
synced 2025-12-19 21:48:01 +01:00
Moved xrandr options to Output class
This commit is contained in:
19
pyrandr.py
19
pyrandr.py
@@ -38,6 +38,16 @@ class Output(object):
|
|||||||
else:
|
else:
|
||||||
return "%s %s %s" % (self.name, connected, active)
|
return "%s %s %s" % (self.name, connected, active)
|
||||||
|
|
||||||
|
def get_randr_options(self):
|
||||||
|
"""Return options for xrandr command as a list"""
|
||||||
|
if self.connected:
|
||||||
|
return ['--output', self.name,
|
||||||
|
'--mode', "%dx%d" % (self.x, self.y),
|
||||||
|
'--pos', "%dx%d" % (self.shift_x, self.shift_y),
|
||||||
|
'--rotate', "normal"]
|
||||||
|
else:
|
||||||
|
return ['--output', self.name, '--off']
|
||||||
|
|
||||||
|
|
||||||
class Organizer(object):
|
class Organizer(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -96,14 +106,7 @@ class Organizer(object):
|
|||||||
cmd = ['xrandr']
|
cmd = ['xrandr']
|
||||||
for name in self._outputs:
|
for name in self._outputs:
|
||||||
out = self._outputs[name]
|
out = self._outputs[name]
|
||||||
if not out.connected:
|
cmd.extend(out.get_randr_options())
|
||||||
cmd.extend(['--output', out.name, '--off'])
|
|
||||||
continue
|
|
||||||
|
|
||||||
cmd.extend(['--output', out.name,
|
|
||||||
'--mode', "%dx%d" % (out.x, out.y),
|
|
||||||
'--pos', "%dx%d" % (out.shift_x, out.shift_y),
|
|
||||||
'--rotate', "normal"])
|
|
||||||
|
|
||||||
subprocess.call(cmd)
|
subprocess.call(cmd)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user