diff --git a/Tests/test_imagegrab.py b/Tests/test_imagegrab.py index 5f51171f1..01fa090dc 100644 --- a/Tests/test_imagegrab.py +++ b/Tests/test_imagegrab.py @@ -43,6 +43,7 @@ class TestImageGrab: if ( sys.platform not in ("win32", "darwin") and not shutil.which("gnome-screenshot") + and not shutil.which("grim") and not shutil.which("spectacle") ): with pytest.raises(OSError) as e: diff --git a/docs/reference/ImageGrab.rst b/docs/reference/ImageGrab.rst index 1e827a676..0fd8f68df 100644 --- a/docs/reference/ImageGrab.rst +++ b/docs/reference/ImageGrab.rst @@ -16,9 +16,9 @@ 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 - fallback if they are installed. To disable this behaviour, pass ``xdisplay=""`` - instead. + 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. .. versionadded:: 1.1.3 (Windows), 3.0.0 (macOS), 7.1.0 (Linux) diff --git a/src/PIL/ImageGrab.py b/src/PIL/ImageGrab.py index 4da14f8e4..c29350b7a 100644 --- a/src/PIL/ImageGrab.py +++ b/src/PIL/ImageGrab.py @@ -89,6 +89,8 @@ def grab( if display_name is None and sys.platform not in ("darwin", "win32"): if shutil.which("gnome-screenshot"): args = ["gnome-screenshot", "-f"] + elif shutil.which("grim"): + args = ["grim"] elif shutil.which("spectacle"): args = ["spectacle", "-n", "-b", "-f", "-o"] else: