bugaevc / wl-clipboard

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

Paste from user clipboard to superuser doesn't work #96

Closed timsofteng closed 4 years ago

timsofteng commented 4 years ago

Hello. When I copy something under ordinary user and then trying to paste it into root wl-clipboard is empty. Is it any solution to fix this behavior?

bugaevc commented 4 years ago

Hi!

What, exactly, do you mean by "to superuser" / "into root"? Do you just run wl-clipboard as root (e.g. sudo wl-paste), or do you run a separate session as root, or what?

Do other Wayland clients work when run that way?

timsofteng commented 4 years ago

Hi!

What, exactly, do you mean by "to superuser" / "into root"? Do you just run wl-clipboard as root (e.g. sudo wl-paste), or do you run a separate session as root, or what?

Do other Wayland clients work when run that way?

I'll try to explain. I'm using neovim. And when I try to edit some system file with sudo nvim /path_to_file.fileI can't use clipboard from non-root user.

bugaevc commented 4 years ago

This is probably because sudo messes with the environment, so you end up with XDG_RUNTIME_DIR unset. It should fail like this:

$ sudo wl-paste 
error: XDG_RUNTIME_DIR not set in the environment.
Failed to connect to a Wayland server

Try using sudo -E to keep the environment.

bugaevc commented 4 years ago

I assume that worked :slightly_smiling_face:

kopr12 commented 2 years ago

Having this problem, I don't use 'sudo' but 'su' , any solution when using that one ?

YaLTeR commented 2 years ago

Maybe su --preserve-environment?

kopr12 commented 2 years ago

Did try that, but I'm getting this : su: ignoring --preserve-environment, it's mutually exclusive with --login

I couldn't overcome that one.