[TIP] Klipper Actions: Manually share clipboard with a device using KDE Connect

Here’s how to manually share the current clipboard with a connected device using Klipper Actions, instead of automatic sharing.

  • First turn off automatic clipboard synchronization in the KDE Connect “Clipboard” plugin, but keep the plugin enabled.

  • Then create a Klipper Action like this:

kdeconnect-cli -d $(kdeconnect-cli -a --id-only) --send-clipboard

Now you can choose what to share and when to share it. :+1: Do you have a useful Klipper Action to share?

4 Likes

I was looking for a solution, as it seems my Android version doesn’t support the automatic clipboard synchronization nor the KDE Connect action to manually share it seems to work. This works, thank you!

1 Like

That’s great!
You can also just run the command in the terminal but it is very useful as a Klipper Action.

That’s also the most logical place where to keep it :laughing:

This is great!

I noticed this happening when implementing this, can you confirm?

1 Like

Yes I can reproduce. The Action Properties pop-up window steals focus from the desktop. I’m on KDE PLasma 6.0.5 using X11.

on kubuntu 24.04 it only sends the top item in klipper.

items below that have the new action i can select, but it still only sends the top item.

Yes, the option “–send-clipboard” sends the current, or top, item in the clipboard. I should have made that clear. Sorry about that.

there must be a way to extract the clipboard item ID and pass it to the action as a variable… after all the edit button knows which item i’m editing.

it seems if i’m clicking on an item to evoke the action menu, then there should be some context that comes with that (like an ID) since the action item button appears on each item, just like the edit button.

i like this tip and would prefer this way of sharing over automatic sync, but if i can’t choose which item to share, it severely limits its utility.

I think the limitation lies in KDE Connect. It can only see the currently selected clipboard item.
I agree it would be more useful if you could share any item in the clipboard. It’s just one extra click though, so it doesn’t bother me.

That is what is so GOOD with this!
I can select the specific line I WANT to transfer to my phone in the clipboard menu on the system tray rather than having every single thing I ctrl+c sent!

image

1 Like

i’m gonna just leave auto sync on so i have access to my entire clipboard.

1 Like

So rather than just being allowed to paste an item, you want to prevent this and put an extra step?

I don’t understand the benefit of this extra limit.

However, it would be kinda cool if you could call (from the phone) for the clipboard list and be able to scroll and select an item from there…

You know, similar to the way you can call for a screenshot:

file=/tmp/$(hostname)_$(date "+%Y%m%d_%H%M%S").png; spectacle -bno "${file}" && kdeconnect-cli -d $(kdeconnect-cli -a --id-only) --share ${file}

It’d be nice to call from the phone for the Klipper history list to select from, but not really much more convenient than reaching to the keyboard and selecting there.

1 Like

There is no “extra limit”. You SELECT what to transfer.

Eeeeh… That is the standard behavior if you activate “automatically share the clipboard from this device”. A behavior I have never liked since I do NOT want every single thing I ctrl+c transferring over to my phone’s clipboard to select from.

1 Like

I personally don’t want to sync everything in the clipboard automatically. I prefer to choose what is being synced. That was the idea. :grinning:

I didn’t appreciate this fact. For example, with Klipper, when I open it’s history I can choose to select any item and hit ‘enter’ to select it for pasting.

I don’t see the option to do that on my phone…

I actually prefer CopyQ, where I have several saved items which are used quite frequently - and I don’t see any way to pull those up on the phone either.

The way I solved it was to add one or two often used items to my ‘autocorrect’ so that ‘tyvm’ will paste ขอบคุณมากครับ เจอกันใหม่ครั้งหน้าครับ and then a few other items were individually pinned to the sidebar (so not really shared, but imported and saved to the phone’s pinned items in the sidebar clipboard history).

Overall it works okay, though I really do fail to see why anyone would not want the clipboard automatically available… Given that both the computer and the phone are private/secure platforms and it poses no security risk.

that only works if you happen to select the top item.

if you select an item lower in the list and choose the “action” button, it will still only send the item at the top.

as ben2talk pointed out tho, if you click on any item in the list the clipboard will move that item into the top spot where you can then use this action to send it.

that’s two steps tho, (three if you count having to open the clipborad again to get the newly positioned item.

suggestion:

if the action could both select and send in the same action, then you could pick any item from the list without having to manually position it in the top spot first (expected behavior).

is that possible?

seems like that should be possible and a valuable addition.

1 Like

That would be very useful! Maybe the Klipper Action could run a little script with xclip or wl-clipboard to replace the current clipboard with the selected clipboard and then send that to your device? :face_with_spiral_eyes:
I’m too dumb and lazy.

Actually, I had to try out my idea and it works great. Install xclip (on X11) and then use this command for the Klipper Action:

echo -n %s | xclip -selection clipboard; kdeconnect-cli -d $(kdeconnect-cli -a --id-only) --send-clipboard

It adds the selected clipboard item back to the top of the clipboard and then sends that to your device.

That’s some hacky stuff, but it’s linux after all. :rofl:

1 Like

brilliant!

works great.

but what’s your wayland solution :wink:

2 Likes