From 5cca90a37ce005498c80f4717ba67c5d8f45c540 Mon Sep 17 00:00:00 2001 From: mihail Date: Mon, 20 Dec 2021 12:08:31 +0300 Subject: [PATCH] Add: XDGViewer which uses xdg-open Synopsis xdg-open { file | URL } xdg-open { --help | --manual | --version } Use 'man xdg-open' or 'xdg-open --manual' for additional info. Conflict:NA Reference:https://github.com/python-pillow/Pillow/commit/5cca90a37ce005498c80f4717ba67c5d8f45c540 --- src/PIL/ImageShow.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/PIL/ImageShow.py b/src/PIL/ImageShow.py index 1ada825..137135e 100644 --- a/src/PIL/ImageShow.py +++ b/src/PIL/ImageShow.py @@ -186,6 +186,16 @@ class UnixViewer(Viewer): os.remove(path) return 1 +class XDGViewer(UnixViewer): + """ + The freedesktop.org ``xdg-open`` command. + """ + + def get_command_ex(self, file, **options): + command = executable = "xdg-open" + return command, executable + + class DisplayViewer(UnixViewer): """The ImageMagick ``display`` command.""" @@ -219,6 +229,8 @@ class XVViewer(UnixViewer): if sys.platform not in ("win32", "darwin"): # unixoids + if shutil.which("xdg-open"): + register(XDGViewer) if shutil.which("display"): register(DisplayViewer) if shutil.which("eog"): -- 2.27.0