diff --git a/Tests/test_imagegrab.py b/Tests/test_imagegrab.py index 5f51171f1..86b2af0c9 100644 --- a/Tests/test_imagegrab.py +++ b/Tests/test_imagegrab.py @@ -44,6 +44,7 @@ class TestImageGrab: sys.platform not in ("win32", "darwin") and not shutil.which("gnome-screenshot") and not shutil.which("spectacle") + and not shutil.which("grim") ): with pytest.raises(OSError) as e: ImageGrab.grab() diff --git a/docs/reference/ImageGrab.rst b/docs/reference/ImageGrab.rst index 1e827a676..af3469a53 100644 --- a/docs/reference/ImageGrab.rst +++ b/docs/reference/ImageGrab.rst @@ -16,7 +16,7 @@ or the clipboard to a PIL image memory. the entire screen is copied, and on macOS, it will be at 2x if on a Retina screen. On Linux, if ``xdisplay`` is ``None`` and the default X11 display does not return - a snapshot of the screen, ``gnome-screenshot`` or ``spectacle`` will be used as a + a snapshot of the screen, ``gnome-screenshot``, ``grim`` or ``spectacle`` will be used as a fallback if they are installed. To disable this behaviour, pass ``xdisplay=""`` instead. diff --git a/src/PIL/ImageGrab.py b/src/PIL/ImageGrab.py index 4da14f8e4..3f5e5743f 100644 --- a/src/PIL/ImageGrab.py +++ b/src/PIL/ImageGrab.py @@ -91,6 +91,8 @@ def grab( args = ["gnome-screenshot", "-f"] elif shutil.which("spectacle"): args = ["spectacle", "-n", "-b", "-f", "-o"] + elif shutil.which("grim"): + args = ["grim"] else: raise fh, filepath = tempfile.mkstemp(".png")