sindresorhus / clipboardy

Access the system clipboard (copy/paste)
MIT License
1.77k stars 81 forks source link

Use Clipboard for Linux, Windows, macOS, and *BSD #92

Open Slackadays opened 1 year ago

Slackadays commented 1 year ago

The project Clipboard now supports X11, Wayland, Windows, and macOS. I realized that you could now switch from using xsel and clipboard.exe and pbcopy to just clipboard for all those platforms at the same time. In addition, this change would also fix https://github.com/sindresorhus/clipboardy/issues/38 due to the new Wayland support too. This also means you can support the BSDs as well!

In the code, you would condense all the different cases except Android into one that just calls clipboard. For the fallbacks, you would just bundle Clipboard for the various platforms you support.

Edit: This would also enable support for Linux/BSD where there isn't X11/Wayland because CB doesn't depend on them to exist.

sindresorhus commented 1 year ago

Thanks for the suggestion. The Windows and macOS variants are working fine, so I wouldn't touch those. Fixing Linux sounds nice though. However, I have some concerns:

  1. It's notoriously hard to ship Linux binaries (ABI incompatibilities, system dependencies, etc). I have a feeling this will cause a lot of support headache.
  2. The code is GPL. Even though that should not apply to the binaries, I could cause licensing issues.
  3. I don't trust anything written in C++. I would have preferred to adopt a binary written in a memory-safe language like Rust.
Slackadays commented 1 year ago
  1. Although this is true, it looks like xsel is already getting shipped which would put CB at no worse a position than before if it was just swapped out.
  2. It looks like xsel has some bespoke license that almost looks like MIT but not quite. xclip and wl-clipboard use GPL, though, so there's that.
  3. I can see where you're coming from. However, consider that all these other utilities are written in C which has zero memory-safe features at all, and CB uses C++20 with enough pointers to count on one hand, so we're in a better position than either C or the "bad old days" of C++98 where it was C but worse.