Skip to content

Commit 674b239

Browse files
committed
Add support for grim in wayland sessions
1 parent eb03954 commit 674b239

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

Tests/test_imagegrab.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def test_grab_no_xcb(self) -> None:
4444
sys.platform not in ("win32", "darwin")
4545
and not shutil.which("gnome-screenshot")
4646
and not shutil.which("spectacle")
47+
and not shutil.which("grim")
4748
):
4849
with pytest.raises(OSError) as e:
4950
ImageGrab.grab()

docs/reference/ImageGrab.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ or the clipboard to a PIL image memory.
1616
the entire screen is copied, and on macOS, it will be at 2x if on a Retina screen.
1717

1818
On Linux, if ``xdisplay`` is ``None`` and the default X11 display does not return
19-
a snapshot of the screen, ``gnome-screenshot`` or ``spectacle`` will be used as a
19+
a snapshot of the screen, ``gnome-screenshot``, ``grim`` or ``spectacle`` will be used as a
2020
fallback if they are installed. To disable this behaviour, pass ``xdisplay=""``
2121
instead.
2222

src/PIL/ImageGrab.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ def grab(
9191
args = ["gnome-screenshot", "-f"]
9292
elif shutil.which("spectacle"):
9393
args = ["spectacle", "-n", "-b", "-f", "-o"]
94+
elif shutil.which("grim"):
95+
args = ["grim"]
9496
else:
9597
raise
9698
fh, filepath = tempfile.mkstemp(".png")

0 commit comments

Comments
 (0)