RPC for copying local clipboard to global clipboard?

I would like to set up a script which uses qubes RPC to copy the current local clipboard to the global clipboard. However I’m not seeing any pre-existing RPC endpoint for that (all endpoints can be found in /etc/qubes-rpc, right?).

Is this not an already existing feature?

I think RPC is not used by default for clipboard:

rpc-clipboard

Use qubes.ClipboardCopy and qubes.ClipboardPaste qubes RPC services to fetch/send clipboard content from/to this qube, instead of using GUI protocol. This is supported (and required) by Qubes Windows Tools.

Default: use GUI protocol for clipboard operations

qvm-features – manage domain’s features — Qubes Admin client mm_af3266e8-0-gaf3266e-dirty documentation

In dom0 the clipboard transfer is done internally and I don’t know if there is an interface for it, you’ll need to check the sources.

GUI virtualization | Qubes OS

Is it possible to use an RPC to copy directly to a different service? I’m not seeing the qubes.CopyClipboard file in /etc/qubes-rpc and I’m not sure how it works.

What do you mean by “local”? The one from the VM that calls the service? Or the one from dom0?

Anyway, as @apparatus linked, clipboard operations are not using standard RPC on dom0 side - it’s all internal to the qubes-guid. It’s a bit faked to pretend to be an RPC service by qubes-guid checking qubes.ClipboardPaste policy before actually sending clipboard anywhere, but no actual RPC call happens - it’s only a message within the GUI protocol.

As for the Windows implementation - there, qubes-guid kinda does RPC calls to a VM to send/retrieve clipboard content, but still, the action is initiated by qubes-guid in dom0 (or GUI domain to be precise). There intentionally is no service for a VM to call to replace global clipboard content - it’s one of the attacks that our implementation prevents (malicious application replacing clipboard content - for example many malwares use that to replace bank account number just before you paste it to make a wire transfer).