-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompositor.py
More file actions
45 lines (33 loc) · 1.23 KB
/
Copy pathcompositor.py
File metadata and controls
45 lines (33 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""Compositor detection for per-WM hotkey adapter routing.
Env-var heuristics chosen for portability:
KDE_FULL_SESSION — set by kstart on KDE Plasma sessions
XDG_CURRENT_DESKTOP — desktop-agnostic, "KDE", "GNOME", "sway", …
HYPRLAND_INSTANCE_SIGNATURE, SWAYSOCK, NIRI_SOCKET — per-compositor runtime sockets
Returns one of:
"x11" | "kde" | "gnome" | "hyprland" | "sway" | "niri" | "wlr"
"wlr" is the generic Wayland fallback (COSMIC, sway w/o SWAYSOCK,
labwc, …) — adapters for it fall back to the manual-instructions path.
"""
import os
from platform_linux import is_wayland
def detect() -> str:
if not is_wayland():
return "x11"
xdg = os.environ.get("XDG_CURRENT_DESKTOP", "").lower()
if os.environ.get("KDE_FULL_SESSION") == "true" or "kde" in xdg or "plasma" in xdg:
return "kde"
if os.environ.get("HYPRLAND_INSTANCE_SIGNATURE"):
return "hyprland"
if os.environ.get("SWAYSOCK"):
return "sway"
if os.environ.get("NIRI_SOCKET"):
return "niri"
if "gnome" in xdg:
return "gnome"
if "hyprland" in xdg:
return "hyprland"
if "sway" in xdg:
return "sway"
if "niri" in xdg:
return "niri"
return "wlr"