dev(hansbug): use scrot when have

This commit is contained in:
HansBug 2023-04-18 12:50:47 +08:00
parent 1321b6e09c
commit 1e092e95ba

View File

@ -61,10 +61,13 @@ def grab(bbox=None, include_layered_windows=False, all_screens=False, xdisplay=N
left, top, right, bottom = bbox left, top, right, bottom = bbox
im = im.crop((left - x0, top - y0, right - x0, bottom - y0)) im = im.crop((left - x0, top - y0, right - x0, bottom - y0))
return im return im
elif shutil.which("gnome-screenshot"): elif shutil.which("gnome-screenshot") or shutil.which("scrot"):
fh, filepath = tempfile.mkstemp(".png") fh, filepath = tempfile.mkstemp(".png")
os.close(fh) os.close(fh)
subprocess.call(["gnome-screenshot", "-f", filepath]) if shutil.which("scrot"): # use scrot when have
subprocess.call([shutil.which("scrot"), "-z", "--overwrite", filepath])
else:
subprocess.call([shutil.which("gnome-screenshot"), "-f", filepath])
im = Image.open(filepath) im = Image.open(filepath)
im.load() im.load()
os.unlink(filepath) os.unlink(filepath)