Use image/png mime type for ImageGrab (wl-paste) if possible, otherwise the first mime type taken

This commit is contained in:
rrcgat 2023-05-23 18:44:25 +08:00
parent c656583b84
commit fffcb558f6
No known key found for this signature in database
GPG Key ID: 8A5698D402519CF8

View File

@ -147,15 +147,12 @@ def grabclipboard():
clipboard_mimetypes = output.splitlines()
def find_mimetype():
for mime in Image.MIME.values():
if mime in clipboard_mimetypes:
return mime
if "image/png" in clipboard_mimetypes:
return "image/png"
if clipboard_mimetypes:
return clipboard_mimetypes[0]
Image.preinit()
mimetype = find_mimetype()
if not mimetype:
Image.init()
mimetype = find_mimetype()
if mimetype:
args.extend(["-t", mimetype])
elif shutil.which("xclip"):