Skip to content

Conversation

@radarhere
Copy link
Member

@radarhere radarhere commented May 6, 2023

Alternative to #7143

#7100 (comment)

although gnome-screenshot is widely present in Linux systems, in newer systems such as Ubuntu 20.04, there will be a full-screen animation effect when taking screenshots, and it is not easy to close. This feature may cause inconvenience to users in some tasks.

For this reason, a later comment in the thread requested that X11 be preferred over gnome-screenshot.

This PR modifies ImageGrab to not use gnome-screenshot if X11 is in use and Pillow has XCB support.

return im
elif shutil.which("gnome-screenshot"):
elif not (
Image.core.HAVE_XCB and os.environ.get("XDG_SESSION_TYPE") == "x11"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if XDG_SESSION_TYPE is not set? Or alternatively, if the X11 connection is not configured properly (e.g. DISPLAY is not set)? The following is set on my Ubuntu 20.04 (in WSL), with the DISPLAY value being valid only when I do not forget to run my X server. I imagine the DISPLAY value could be invalid for other reasons as well.

$ set | grep DISPLAY
DISPLAY=:0
$ set | grep XDG
XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop
    local -a dirs=(${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions);
    for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share};
$

I think a better option is to use a try-except block instead to prefer X11 over gnome-screenshot: #7143

@radarhere
Copy link
Member Author

Closing in favour of #7143

@radarhere radarhere closed this May 13, 2023
@radarhere radarhere deleted the x11 branch May 13, 2023 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants