clipboard-screenshot
Clipboard screenshot
The user's clipboard is invisible to you. A small bridge on this machine makes it reachable: connect to its Unix socket and it writes the clipboard's current contents to you and closes. When the clipboard holds a screenshot, those bytes are a PNG (sometimes another image format).
The socket is $HOME/.clipboard.sock ($CLIPBOARD_SOCKET overrides it).
Living in the home directory is what makes several users on one machine safe:
each login's bridge — or forwarded socket, via
RemoteForward /home/%r/.clipboard.sock <local> in ssh config — sits in its
own home, so paths cannot collide and a grab can never read (or be fed by)
someone else's bridge. Never point CLIPBOARD_SOCKET at another user's
socket: that is their clipboard, not the user's.
That gives you a path from "the user copied a picture" to "you are looking at the
picture" — the missing step is that image bytes only enter your context by way of
a file you Read, so the bytes have to land on disk first, under a name whose
extension matches what they actually are.