Do not use gnome-screenshot on Linux if X11 can be used instead#7139
Closed
radarhere wants to merge 1 commit intopython-pillow:mainfrom
Closed
Do not use gnome-screenshot on Linux if X11 can be used instead#7139radarhere wants to merge 1 commit intopython-pillow:mainfrom
radarhere wants to merge 1 commit intopython-pillow:mainfrom
Conversation
nulano
reviewed
May 8, 2023
| return im | ||
| elif shutil.which("gnome-screenshot"): | ||
| elif not ( | ||
| Image.core.HAVE_XCB and os.environ.get("XDG_SESSION_TYPE") == "x11" |
Contributor
There was a problem hiding this comment.
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
Member
Author
|
Closing in favour of #7143 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to #7143
#7100 (comment)
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.