Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Tests/test_imagegrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def test_grab_no_xcb(self) -> None:
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:
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/ImageGrab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions src/PIL/ImageGrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
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"]

Check warning on line 93 in src/PIL/ImageGrab.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/ImageGrab.py#L93

Added line #L93 was not covered by tests
elif shutil.which("spectacle"):
args = ["spectacle", "-n", "-b", "-f", "-o"]
else:
Expand Down
Loading