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:
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(?).
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 aboutHAS_DISPLAY
could look like this:PR #201 does something very similar, but seems to be ignored(?).