summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2023-12-23 12:27:07 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2023-12-23 12:27:07 +0100
commit54f5d1ab635718d8fc3f8d05f921ede7924dbc22 (patch)
treefdacfd20e44c90c076839b561cb20d180a649a64
parent6980b2732971f7c12df7f65ba3692f6a49418562 (diff)
Use a different mechanism to check if wayland is supportedHEADmain
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
-rw-r--r--debian/changelog7
-rw-r--r--monitor_menu/__main__.py18
2 files changed, 19 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog
index b3a275f..46c8f68 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+monitor-menu (0.4) lunar; urgency=medium
+
+ * Use a different mechanism to check if we are running wayland or xorg.
+ Running xrandr succeeds on wayland if xwayland is used.
+
+ -- Olivier Gayot <olivier.gayot@sigexec.com> Mon, 15 May 2023 18:19:57 +0200
+
monitor-menu (0.3) lunar; urgency=medium
* By default, do not exit the menu after applying a profile. Can be
diff --git a/monitor_menu/__main__.py b/monitor_menu/__main__.py
index 5670954..b1811f6 100644
--- a/monitor_menu/__main__.py
+++ b/monitor_menu/__main__.py
@@ -5,6 +5,7 @@ import dataclasses
import enum
import json
import logging
+import os
import pathlib
import subprocess
from typing import Any
@@ -71,18 +72,23 @@ class Profile:
return cls(**kwargs)
def apply(self, graphical_server: GraphicalServer | None):
+ if graphical_server is None:
+ try:
+ graphical_server = GraphicalServer(os.environ["XDG_SESSION_TYPE"])
+ except KeyError:
+ if "WAYLAND_DISPLAY" in os.environ:
+ graphical_server = GraphicalServer.WAYLAND
+ elif "DISPLAY" in os.environ:
+ graphical_server = GraphicalServer.XORG
+
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()
+ log.debug("Cannot determine graphical server type")
+ raise Exception
def apply_xorg(self):
# We build the command line starting from just "xrandr" and adding