Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipboard does not work on Wayland / Sway #210

Open
zupd opened this issue Feb 3, 2024 · 14 comments
Open

Clipboard does not work on Wayland / Sway #210

zupd opened this issue Feb 3, 2024 · 14 comments
Assignees
Labels
bug Something isn't working need more info

Comments

@zupd
Copy link

zupd commented Feb 3, 2024

Describe the bug
When using Wayland / Sway passwords wont get copied to the clipboard.

To Reproduce
Steps to reproduce the behavior:

  1. Use wayland / sway
  2. run dcli password <title>

Expected behavior
Password should get copied to clipboard

Screenshots

Environment (please complete the following information):

  • OS: Linux Ubuntu 23.04
  • display server protocol: Wayland
  • compositor (window manager): Sway

Additional context
The reason why this happens is because wayland dont use xsel / xcopy to copy to clipboard. it uses wl-copy instead. And there is currently no support for this in the clipboardy package that dashlane CLI uses.

@zupd zupd added the bug Something isn't working label Feb 3, 2024
@Mikescops
Copy link
Contributor

Hello,
Thanks for reporting this, I'm surprised because we don't use "clipboardy" package but an implementation in Rust that should work with wayland.
Can you confirm you're running the latest version of the CLI please?

@Mikescops
Copy link
Contributor

Hello,
Just a reminder on this issue, if I get no answer this week I'll close it but you can feel free to comment anytime to reopen it of course.
Thanks a lot!

@Mikescops Mikescops self-assigned this Apr 8, 2024
@Mikescops Mikescops closed this as not planned Won't fix, can't repro, duplicate, stale Apr 19, 2024
@zupd
Copy link
Author

zupd commented Apr 19, 2024

Sorry, I'll check this today

@zupd
Copy link
Author

zupd commented Jun 24, 2024

@Mikescops Sorry for not responding in a while. When I tested this in february I was running version 1.15.0.
Today I updated the client to 6.2424.2 and I can confirm the clipboard functionality is working as intended yes.

@Mikescops
Copy link
Contributor

@zupd awesome thanks!

@JonahWeinbaum
Copy link

This issue is still present on current version.

@zupd
Copy link
Author

zupd commented Oct 29, 2024

This issue is still present on current version.

I can confirm this @Mikescops . It seems that when I tested this first, it was on Ubuntu 23.04, and when I tested it the second time I was on Debian 12 which also uses wayland. And I assumed it worked in the latest version now, since it worked on Debian 12, but when I now tried it on my Ubuntu again it won't copy to my clipboard. This is on the latest version of dcli.

~/Downloads$ wl-copy 'TEST123'
~/Downloads$ wl-paste
TEST123
~/Downloads$ dcli p github
🔓 password for "GitHub" copied to clipboard!
~/Downloads$ wl-paste
No selection

It almost seems like dcli resets the clipboard and doesnt copy anything into it

@JonahWeinbaum
Copy link

JonahWeinbaum commented Oct 30, 2024

I will test a theory in the morning but it seems that the clipboard package being used will do an ANSI OSC52 sequence to copy if it detects it is being run from within ssh, which should work fine with sway.

If anyone desires to test this, my working theory is that if you are running ssh inside of sway this would work fine. I'm not at my sway desktop currently but will examine further.

@Mikescops Mikescops reopened this Oct 30, 2024
@JonahWeinbaum
Copy link

JonahWeinbaum commented Oct 30, 2024

Okay after further examination here are some notes. Your package uses napi-rs/clipboard which, under normal circumstances, uses arboard clipboard, which itself has a flag that can be used during compilation of wayland-data-control. I imagine this could aid in solving such problems since this uses wl-copy as a secondary copying method.

As they note

There's also an optional wayland data control backend through the wl-clipboard-rs crate. This can be enabled
 using the wayland-data-control feature. When enabled this will be prioritized over the X11 backend, but if the 
initialization fails, the implementation falls back to using the X11 protocol automatically. Note that in my tests the 
wayland backend did not keep the clipboard contents after the process exited.

EDIT: I am wrong, further examination shows napi-rs/clipboard compiles arboard with wayland-data-control. A real head scrathcher. I will test each dependency when I am back at my main computer. Too many dependencies deep...

@JonahWeinbaum
Copy link

JonahWeinbaum commented Oct 30, 2024

Okay quick update. This problem goes all the way down to arboard. Arboard can successfully retrieve clipboard data in sway but cannot copy to the clipboard even with the wayland-data-control feature...

$ ./target/debug/copy
Clipboard text was: test
But now the clipboard text should be: "Hello, world!"
$ wl-paste
Nothing is copied

@zupd
Copy link
Author

zupd commented Oct 30, 2024

Okay quick update. This problem goes all the way down to arboard. Arboard can successfully retrieve clipboard data in sway but cannot copy to the clipboard even with the wayland-data-control feature...

$ ./target/debug/copy
Clipboard text was: test
But now the clipboard text should be: "Hello, world!"
$ wl-paste
Nothing is copied

This looks just like my test with dashlane when I had something in the clipboard, then ran dashlane and then clipboard was empty

@Mikescops
Copy link
Contributor

Hey guys, thanks for your nice investigation.

As arboard author mentioned Note that in my tests the wayland backend did not keep the clipboard contents after the process exited. which seems to match the behaviour we have here, you copy something, the process exit, and the content disappear from clipboard.

I think it will be hard to support every environments with the clipboard functionality, do you think it's acceptable to output the password directly so it can be piped into wl-copy? If so we can just suggest such command in our documentation.

@zupd
Copy link
Author

zupd commented Nov 1, 2024

Hey guys, thanks for your nice investigation.

As arboard author mentioned Note that in my tests the wayland backend did not keep the clipboard contents after the process exited. which seems to match the behaviour we have here, you copy something, the process exit, and the content disappear from clipboard.

I think it will be hard to support every environments with the clipboard functionality, do you think it's acceptable to output the password directly so it can be piped into wl-copy? If so we can just suggest such command in our documentation.

It already supports that, right? if you use -o console. though I noticed that it also includes the "password for .. copied to clipboard". Seems strange that it says that when you use console as output instead of clipboard

@Mikescops
Copy link
Contributor

@zupd definitely a bug, I'll take a look thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need more info
Projects
None yet
Development

No branches or pull requests

3 participants