PTClipboard
As I was switching to Linux, so did my code base. I admit, most of code didn’t really care on which platform it was running but I wasn’t so fortunate with all of it. One annoying issue was clipboard handling. Linux simply did its clipboard differently. So I decided to solve this problem for me. Twice.
My first attempt at solving this problem was a simple X11 clipboard library. It worked like a charm. And then the whole migration toward Wayland happened. While most desktop environments still have X11 compatibility, writing was on the wall for this one.
So, I decided to expand functionality a bit. The new library still supports handling X11 clipboard text. And to it adds both Wayland and Windows support. That way the same library can be used in a really cross-platform manner. Well, almost cross-platform - MacOS support is missing as I don’t really have any devices to test it on.
Now, this library is small in scope - only plain-text is supported. While I do have plans to adjust this a bit, I doubt it will go much beyond this. Idea is to have it as simple as possible, not to provide the full clipboard access. And simple it is:
using Medo;
PTClipboard.SetText("My text.");
var text = PTClipboard.GetText();And that is pretty much all. Yes, there is also support for primary selection under linux (aka as “middle-click clipboard”) with syntax just slightly longer:
using Medo;
PTClipboard.Selection.SetText("My text.");
var text = PTClipboard.Selection.GetText();And setup is pretty much non-existent as code should detect system it is running on automatically.
You can get package at NuGet and check source code at GitHub.