aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-02-01 02:00:38 -0600
committerCraig Jennings <c@cjennings.net>2026-02-01 02:00:38 -0600
commit5e6c45b1459d13b4d15065119a75f176919a7221 (patch)
treec597279efb7314ffef2647436e3e07dede3fa68f
parent6511c191de41f4d3a19fecc95a0de512b680d0b2 (diff)
downloaddotemacs-5e6c45b1459d13b4d15065119a75f176919a7221.tar.gz
dotemacs-5e6c45b1459d13b4d15065119a75f176919a7221.zip
feat(env): add X11 and Wayland detection functions
env-x11-p returns t when on X11 (not Wayland). env-wayland-p checks WAYLAND_DISPLAY env var, works with XWayland.
-rw-r--r--modules/host-environment.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/host-environment.el b/modules/host-environment.el
index 3cec5df1..af9248c2 100644
--- a/modules/host-environment.el
+++ b/modules/host-environment.el
@@ -44,6 +44,17 @@
"Return t if host system is running the X Window System."
(string= (window-system) "x"))
+(defun env-x11-p ()
+ "Return t if running under X11 (not Wayland)."
+ (and (eq (window-system) 'x)
+ (not (getenv "WAYLAND_DISPLAY"))))
+
+(defun env-wayland-p ()
+ "Return t if running under Wayland.
+Checks WAYLAND_DISPLAY env var, which is set by Wayland compositors.
+This returns t even if Emacs is running through XWayland."
+ (and (getenv "WAYLAND_DISPLAY") t))
+
(defun env-terminal-p ()
"Return t if running in a terminal."
(not (display-graphic-p)))