mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +03:00
Check session type using environment variable instead of loginctl
This commit is contained in:
parent
7b157b045a
commit
0b6ab79145
|
@ -140,27 +140,10 @@ def grabclipboard():
|
||||||
return BmpImagePlugin.DibImageFile(data)
|
return BmpImagePlugin.DibImageFile(data)
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
if shutil.which("loginctl"):
|
if os.getenv("WAYLAND_DISPLAY"):
|
||||||
try:
|
sessiontype = "wayland"
|
||||||
loginctl = subprocess.check_output("loginctl").decode().split("\n")
|
elif os.getenv("DISPLAY"):
|
||||||
except subprocess.CalledProcessError:
|
sessiontype = "x11"
|
||||||
loginctl = None
|
|
||||||
else:
|
|
||||||
loginctl = None
|
|
||||||
|
|
||||||
if loginctl is not None:
|
|
||||||
username = os.getlogin()
|
|
||||||
sessionid = [
|
|
||||||
line.split()[0] for line in loginctl if username in line.split()
|
|
||||||
][0]
|
|
||||||
sessiontype = (
|
|
||||||
subprocess.check_output(
|
|
||||||
["loginctl", "show-session", sessionid, "-p", "Type"]
|
|
||||||
)
|
|
||||||
.decode()
|
|
||||||
.strip("\n")
|
|
||||||
.split("=")[1]
|
|
||||||
)
|
|
||||||
else: # Session type check failed
|
else: # Session type check failed
|
||||||
sessiontype = None
|
sessiontype = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user