this post was submitted on 11 May 2024
556 points (96.8% liked)

Programmer Humor

19831 readers
195 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 37 points 7 months ago (2 children)

Gee, X11! How come your mom lets you have THREE clipboards?

[–] [email protected] 19 points 7 months ago

then theyre all ignored by x-clip

xD

[–] whats_all_this_then 7 points 7 months ago (1 children)

Wait is that an actual thing?

[–] [email protected] 27 points 7 months ago* (last edited 7 months ago) (2 children)

Yes. X11 replaced X10's obsolete cut buffers (which can be modified by any process) with state-of-the-art selections. There are three selections in X11: a primary, a secondary, and a clipboard.

In modern desktops, the primary selection is overwritten every time you select some text (including in the terminal), which makes its content very ephemeral. You can paste it with the middle mouse button.

The secondary selection is generally not used, but it's present in the specification, and you can use xclip -selection secondary to access it. Wayland doesn't seem to have a secondary selection.

The clipboard selection is what most people understand to be THE clipboard. You have to write to it explicitly (through a keyboard shortcut, API, or CLI tool), and its content persists until it is overwritten, explicitly cleared, or the X server is killed. While the primary and secondary can only contain text, the clipboard can contain many kinds of data.

[–] [email protected] 3 points 7 months ago

In modern desktops, the primary selection is overwritten every time you select some text

( °O°)
You just opened a whole new world for me, it works in Wayland too

[–] whats_all_this_then 2 points 7 months ago (2 children)

Okay I had no.idea. So on Plasma, I'm guessing when I copy anything, it's writing it both the primary selection, and the clipboard selection and that's how it stays in the clipboard manager thingy?

[–] [email protected] 1 points 7 months ago

Not exactly. When you select a text and copy it, the two selections will end up containing the same text, but you can write to either selection without affecing the other by using an API, e.g. a website's "copy to clipboard" button, or xclip/wl-copy.

Clipboard managers with a history feature are an altogether different layer on top of the standard selections. Plasma's clipboard manager only cares about the clipboard selection, and even then, there are exceptions (e.g. copying a password for KeepassXC doesn't save it in the history).

[–] [email protected] 1 points 7 months ago

Plasma has a setting to synchronize selection and clipboard or something like that.