Merge branch 'testing'
This commit is contained in:
@@ -28,6 +28,7 @@ import gi
|
||||
gi.require_version("Atspi", "2.0")
|
||||
from gi.repository import Atspi
|
||||
import os
|
||||
import shutil
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -233,6 +234,42 @@ def inGraphicalDesktop():
|
||||
|
||||
return display is not None
|
||||
|
||||
def getSessionType():
|
||||
sessionType = (os.environ.get("XDG_SESSION_TYPE") or "").strip().lower()
|
||||
if sessionType:
|
||||
return sessionType
|
||||
if os.environ.get("WAYLAND_DISPLAY"):
|
||||
return "wayland"
|
||||
if os.environ.get("DISPLAY"):
|
||||
return "x11"
|
||||
return "unknown"
|
||||
|
||||
def getXServerVendor():
|
||||
display = os.environ.get("DISPLAY")
|
||||
if not display:
|
||||
return None
|
||||
|
||||
xdpyinfoPath = shutil.which("xdpyinfo")
|
||||
if not xdpyinfoPath:
|
||||
return None
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
[xdpyinfoPath, "-display", display],
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
timeout=1,
|
||||
)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
for line in result.stdout.splitlines():
|
||||
if "vendor string:" in line:
|
||||
return line.split("vendor string:", 1)[1].strip()
|
||||
return None
|
||||
|
||||
def otherCthulhus():
|
||||
"""Returns the pid of any other instances of Cthulhu owned by this user."""
|
||||
|
||||
@@ -285,6 +322,29 @@ def main():
|
||||
print(messages.CLI_NO_DESKTOP_ERROR)
|
||||
return 1
|
||||
|
||||
sessionType = getSessionType()
|
||||
sessionDetails = []
|
||||
xdgSessionType = os.environ.get("XDG_SESSION_TYPE")
|
||||
if xdgSessionType:
|
||||
sessionDetails.append(f"XDG_SESSION_TYPE={xdgSessionType}")
|
||||
if sessionType == "wayland":
|
||||
waylandDisplay = os.environ.get("WAYLAND_DISPLAY")
|
||||
if waylandDisplay:
|
||||
sessionDetails.append(f"WAYLAND_DISPLAY={waylandDisplay}")
|
||||
elif sessionType == "x11":
|
||||
display = os.environ.get("DISPLAY")
|
||||
if display:
|
||||
sessionDetails.append(f"DISPLAY={display}")
|
||||
vendor = getXServerVendor()
|
||||
if vendor:
|
||||
sessionDetails.append(f"X server vendor={vendor}")
|
||||
|
||||
if sessionDetails:
|
||||
msg = f"INFO: Session: {sessionType} ({', '.join(sessionDetails)})"
|
||||
else:
|
||||
msg = f"INFO: Session: {sessionType}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
|
||||
debug.printMessage(debug.LEVEL_INFO, "INFO: Preparing to launch.", True)
|
||||
|
||||
from cthulhu import cthulhu
|
||||
|
||||
@@ -28,6 +28,7 @@ import gi
|
||||
gi.require_version("Atspi", "2.0")
|
||||
from gi.repository import Atspi
|
||||
import os
|
||||
import shutil
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -191,6 +192,42 @@ def inGraphicalDesktop():
|
||||
|
||||
return display is not None
|
||||
|
||||
def getSessionType():
|
||||
sessionType = (os.environ.get("XDG_SESSION_TYPE") or "").strip().lower()
|
||||
if sessionType:
|
||||
return sessionType
|
||||
if os.environ.get("WAYLAND_DISPLAY"):
|
||||
return "wayland"
|
||||
if os.environ.get("DISPLAY"):
|
||||
return "x11"
|
||||
return "unknown"
|
||||
|
||||
def getXServerVendor():
|
||||
display = os.environ.get("DISPLAY")
|
||||
if not display:
|
||||
return None
|
||||
|
||||
xdpyinfoPath = shutil.which("xdpyinfo")
|
||||
if not xdpyinfoPath:
|
||||
return None
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
[xdpyinfoPath, "-display", display],
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
timeout=1,
|
||||
)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
for line in result.stdout.splitlines():
|
||||
if "vendor string:" in line:
|
||||
return line.split("vendor string:", 1)[1].strip()
|
||||
return None
|
||||
|
||||
def otherCthulhus():
|
||||
"""Returns the pid of any other instances of Cthulhu owned by this user."""
|
||||
|
||||
@@ -243,6 +280,29 @@ def main():
|
||||
print(messages.CLI_NO_DESKTOP_ERROR)
|
||||
return 1
|
||||
|
||||
sessionType = getSessionType()
|
||||
sessionDetails = []
|
||||
xdgSessionType = os.environ.get("XDG_SESSION_TYPE")
|
||||
if xdgSessionType:
|
||||
sessionDetails.append(f"XDG_SESSION_TYPE={xdgSessionType}")
|
||||
if sessionType == "wayland":
|
||||
waylandDisplay = os.environ.get("WAYLAND_DISPLAY")
|
||||
if waylandDisplay:
|
||||
sessionDetails.append(f"WAYLAND_DISPLAY={waylandDisplay}")
|
||||
elif sessionType == "x11":
|
||||
display = os.environ.get("DISPLAY")
|
||||
if display:
|
||||
sessionDetails.append(f"DISPLAY={display}")
|
||||
vendor = getXServerVendor()
|
||||
if vendor:
|
||||
sessionDetails.append(f"X server vendor={vendor}")
|
||||
|
||||
if sessionDetails:
|
||||
msg = f"INFO: Session: {sessionType} ({', '.join(sessionDetails)})"
|
||||
else:
|
||||
msg = f"INFO: Session: {sessionType}"
|
||||
debug.printMessage(debug.LEVEL_INFO, msg, True)
|
||||
|
||||
debug.printMessage(debug.LEVEL_INFO, "INFO: Preparing to launch.", True)
|
||||
|
||||
from cthulhu import cthulhu
|
||||
|
||||
Reference in New Issue
Block a user