asweigart / pyperclip

Python module for cross-platform clipboard functions.
https://pypi.python.org/pypi/pyperclip
BSD 3-Clause "New" or "Revised" License
1.6k stars 193 forks source link

Running on Wayland causes no clipboard mechanism to be found if `$DISPLAY` is undefined #220

Open MultisampledNight opened 2 years ago

MultisampledNight commented 2 years ago

The environment variable DISPLAY is not ensured to be defined on Wayland (such as on my machine, Arch Linux with Sway), which causes the whole "running on Linux" check to be only useful for X11:

https://github.com/asweigart/pyperclip/blob/781603ea491eefce3b58f4f203bf748dbf9ff003/src/pyperclip/__init__.py#L66 https://github.com/asweigart/pyperclip/blob/781603ea491eefce3b58f4f203bf748dbf9ff003/src/pyperclip/__init__.py#L562-L563

I'd say adding an explicit check for the environment variable WAYLAND_DISPLAY would be the least intrusive and simplest solution. By that, the line about HAS_DISPLAY could look like this:

HAS_DISPLAY = os.getenv("DISPLAY", False) or os.getenv("WAYLAND_DISPLAY", False)

PR #201 does something very similar, but seems to be ignored(?).