From 73694dd6a56de284c91778ae609534fd867262f3 Mon Sep 17 00:00:00 2001 From: Desyncfy Date: Tue, 22 Oct 2024 17:39:04 -0700 Subject: [PATCH] Print NotImplementedError if not using X11 on Linux. --- pyautogui/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyautogui/__init__.py b/pyautogui/__init__.py index 43aebd5..9226f09 100644 --- a/pyautogui/__init__.py +++ b/pyautogui/__init__.py @@ -541,7 +541,11 @@ def isShiftCharacter(character): elif sys.platform == "win32": from . import _pyautogui_win as platformModule elif platform.system() == "Linux": - from . import _pyautogui_x11 as platformModule + # detect X11 + if "x11" in os.environ['XDG_SESSION_TYPE']: + from . import _pyautogui_x11 as platformModule + else: + raise NotImplementedError("Your display server (%s) is not supported by PyAutoGUI." % (os.environ.get('XDG_SESSION_TYPE', 'Unknown'))) else: raise NotImplementedError("Your platform (%s) is not supported by PyAutoGUI." % (platform.system()))