Wl-copy doesn't integrate with system clipboard

Hello, I’m trying to debug why pasting from a wl-copy doesn’t work on my Wayland/GNOME
install.

In GDM, when I log in I choose “GNOME” session type, so it seems like I’m in a
Wayland session.

$ echo $XDG_SESSION_TYPE
wayland
$ echo $WAYLAND_DISPLAY
wayland-0
$ gnome-shell --version
GNOME Shell 46.10

Then in the terminal I can run these commands.

$ echo "hi" | wl-copy
$ wl-paste
hi

So far so good, except I can’t paste hi with the normal system shortcuts. If
I press ctrl+shift+v in the terminal, no paste happens. If I press ctrl+v
in Librewolf, GNOME text editor, or any graphical app—nothing happens, no
paste.

I’ve also tried wl-copy --primary and wl-copy --foreground, but those made
no difference.

If I highlight text and then right-click in the terminal or any GUI app, then
ctrl+v paste works fine.

Not sure but I think under Wayland a lot of this is running via dbus, so maybe some env vars are not matching between your terminal and GUI session.

For example to get to work, taking a screenshot in a script, I ran under Rasbian via cron, I had to get the Wayland env vars WAYLAND_DISPLAY, XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS from a process I knew had them.

(export $(tr '\0' '\n' < /proc/$(pgrep Xwayland)/environ | grep -E 'WAYLAND_DISPLAY|XDG_RUNTIME_DIR|DBUS_SESSION_BUS_ADDRESS' | awk '{print}' ORS=' ') ; grim  -t ppm -g "$RECT" "$TEMPLATE_IMAGE" >/dev/null 2>&1)