summaryrefslogtreecommitdiff
path: root/monitor_menu/__main__.py
diff options
context:
space:
mode:
Diffstat (limited to 'monitor_menu/__main__.py')
-rw-r--r--monitor_menu/__main__.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/monitor_menu/__main__.py b/monitor_menu/__main__.py
index 87719e7..5670954 100644
--- a/monitor_menu/__main__.py
+++ b/monitor_menu/__main__.py
@@ -71,17 +71,18 @@ class Profile:
return cls(**kwargs)
def apply(self, graphical_server: GraphicalServer | None):
- if graphical_server == "xorg":
- self.apply_xorg()
- elif graphical_server == "wayland":
- self.apply_wayland()
- else:
- try:
- subprocess.run(["xrandr"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
- except (subprocess.CalledProcessError, FileNotFoundError):
- self.apply_wayland()
- else:
+ match graphical_server:
+ case GraphicalServer.XORG:
self.apply_xorg()
+ case GraphicalServer.WAYLAND:
+ self.apply_wayland()
+ case None:
+ try:
+ subprocess.run(["xrandr"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+ except (subprocess.CalledProcessError, FileNotFoundError):
+ self.apply_wayland()
+ else:
+ self.apply_xorg()
def apply_xorg(self):
# We build the command line starting from just "xrandr" and adding
@@ -172,7 +173,8 @@ def load_profiles_config(path: pathlib.Path | None):
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--log-level", "--loglevel", type=LogLevel, default="info")
- parser.add_argument("--graphical-server", choices=("wayland", "xorg"), type=GraphicalServer)
+ parser.add_argument("--graphical-server", choices=list(GraphicalServer),
+ type=GraphicalServer)
parser.add_argument(
"--profiles-config",
metavar="PATH",