mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-03 19:33:07 +03:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
bc658e1791
commit
164ea2df6f
|
@ -146,18 +146,27 @@ def grabclipboard():
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
loginctl = None
|
loginctl = None
|
||||||
else:
|
else:
|
||||||
loginctl = None
|
loginctl = None
|
||||||
|
|
||||||
if loginctl is not None:
|
if loginctl is not None:
|
||||||
username = subprocess.check_output("whoami").decode().strip("\n")
|
username = subprocess.check_output("whoami").decode().strip("\n")
|
||||||
sessionid = [line.split()[0] for line in loginctl if username in line.split()][0]
|
sessionid = [
|
||||||
sessiontype = subprocess.check_output(
|
line.split()[0] for line in loginctl if username in line.split()
|
||||||
["loginctl", "show-session", sessionid, "-p", "Type"]
|
][0]
|
||||||
).decode().strip("\n").split("=")[1]
|
sessiontype = (
|
||||||
else: # Session type check failed
|
subprocess.check_output(
|
||||||
|
["loginctl", "show-session", sessionid, "-p", "Type"]
|
||||||
|
)
|
||||||
|
.decode()
|
||||||
|
.strip("\n")
|
||||||
|
.split("=")[1]
|
||||||
|
)
|
||||||
|
else: # Session type check failed
|
||||||
sessiontype = None
|
sessiontype = None
|
||||||
|
|
||||||
if shutil.which("wl-paste") and ((sessiontype == "wayland") or (sessiontype is None)):
|
if shutil.which("wl-paste") and (
|
||||||
|
(sessiontype == "wayland") or (sessiontype is None)
|
||||||
|
):
|
||||||
output = subprocess.check_output(["wl-paste", "-l"]).decode()
|
output = subprocess.check_output(["wl-paste", "-l"]).decode()
|
||||||
mimetypes = output.splitlines()
|
mimetypes = output.splitlines()
|
||||||
if "image/png" in mimetypes:
|
if "image/png" in mimetypes:
|
||||||
|
@ -170,7 +179,9 @@ def grabclipboard():
|
||||||
args = ["wl-paste"]
|
args = ["wl-paste"]
|
||||||
if mimetype:
|
if mimetype:
|
||||||
args.extend(["-t", mimetype])
|
args.extend(["-t", mimetype])
|
||||||
elif shutil.which("xclip") and ((sessiontype == "x11") or (sessiontype is None)):
|
elif shutil.which("xclip") and (
|
||||||
|
(sessiontype == "x11") or (sessiontype is None)
|
||||||
|
):
|
||||||
args = ["xclip", "-selection", "clipboard", "-t", "image/png", "-o"]
|
args = ["xclip", "-selection", "clipboard", "-t", "image/png", "-o"]
|
||||||
else:
|
else:
|
||||||
msg = "wl-paste or xclip is required for ImageGrab.grabclipboard() on Linux"
|
msg = "wl-paste or xclip is required for ImageGrab.grabclipboard() on Linux"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user