This commit is contained in:
Adian Kozlica 2025-04-19 19:51:34 +00:00 committed by GitHub
commit dfbef204c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 1 deletions

View File

@ -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:

View File

@ -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.

View File

@ -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: