From 6bb15ea6d3ce0dbba98c35e523d0a7a6dc91d5e3 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Wed, 5 Feb 2020 19:16:51 -0300 Subject: [PATCH] Implemented get/set_primary --- xrandroll/xrandr.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xrandroll/xrandr.py b/xrandroll/xrandr.py index feab904..e5851a7 100644 --- a/xrandroll/xrandr.py +++ b/xrandroll/xrandr.py @@ -54,6 +54,17 @@ class Screen: candidate = name return candidate + def get_primary(self): + """Return the primary monitor, if any.""" + for mon in self.monitors.values(): + if mon.primary: + return mon + return None + + def set_primary(self, name): + for mon in self.monitors.values(): + mon.primary = name == mon.output + def read_data(): data = subprocess.check_output(