bugaevc / wl-clipboard

Command-line copy/paste utilities for Wayland
GNU General Public License v3.0
1.62k stars 60 forks source link

Couldn't connect to the Wayland compositor #179

Closed LGDHuaOPER closed 1 year ago

LGDHuaOPER commented 1 year ago

I exec that cmd:

WAYLAND_DEBUG=1 wl-copy whatever-you-were-doing

But got error:

Error: Couldn't connect to the Wayland compositor
Caused by:
    Could not find a listening wayland compositor.

I have install sudo apt-get install libwayland-dev and set export XDG_RUNTIME_DIR="$HOME/.wl-clipboard/temp". Why this?

My OS is:

PS C:\Users\HuaFEEng> wsl --list -v
NAME                   STATE           VERSION
* Ubuntu-20.04           Running         2   

huafeeng@Hua-Lenovo-DT:~$ uname -a
Linux Hua-Lenovo-DT 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux   

Thanks!

bugaevc commented 1 year ago

Hi!

You have to have a Wayland compositor running to use wl-clipboard -- otherwise, where would it copy and paste from? Please see the Microsoft docs about using Wayland on WSL 2.

Also setting XDG_RUNTIME_DIR to a custom value is not going to help anything. wl-clipboard doesn't store its temporary files there (that'd be in /tmp), but this directory is the canonical place where libwayland-client looks for a Wayland compositor socket.