Can Clipboard Manager history be exported?

(Probably) because I’ve set the Clipboard Manager’s maximum history entries to the plasmoid’s maximum

Consequently, I’d like to clear its history whilst retaining its history for myself. However, there doesn’t appear to be any obvious option in its GUI, like checkboxes allowing me to perform Ctrl+A to select all and copy them into one \n-delimited paragraph.

No, it’s not the X/Y problem - I do want a record of everything that I’ve duplicated into the clipboard.


I’ve tried

xclip -o

as a workaround, but it doesn’t print anything, weirdly. And I expect that it would solely provide the textual content of the clipboard anyway (text - How does X11 clipboard handle multiple data formats? - Stack Overflow).

This qdbus command will display the entire clipboard history, so redirect to a file as required:

qdbus org.kde.klipper /klipper org.kde.klipper.klipper.getClipboardHistoryMenu

Then you can clear it with the GUI.

2 Likes

Brilliant, @ajgringo619!


Do you know whether there’s a way to poll the amount of entries currently in the clipboard history so that I can automatically export and clear it programmatically in the background, should it reach 2048 entries?

I ask because I haven’t been able to find a QDbus command to clear it. Apologies if I’m being stupid. How to run (Q)Dbus for Qt5/6 from CLI? - Applications - openSUSE Forums hasn’t been answered yet.

qdbus org.kde.klipper /klipper will get you a list of available commands. One of these commands should work, although I haven’t tested it:

qdbus org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardContents
qdbus org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory
2 Likes

I usually clear the clipboard with

qdbus org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory && xclip -sel c -i < /dev/null
3 Likes

A basic draft of the answer is below in case it’s useful. Thanks for all of your help.

@rokejulianlockhart,

https://gitlab.com/rokejulianlockhart/RTBJK9/-/commit/1f04a9f8dba7e0bbd1f7e1a9ddcf7e62d5816def

#!/usr/bin/env -S pwsh-preview

$ClipboardContent = qdbus6 org.kde.klipper /klipper org.kde.klipper.klipper.getClipboardHistoryMenu
Add-Content -Path '' -Value "$ClipboardContent"
qdbus6 org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardContents
qdbus6 org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory

This is fantastic. I’ve had to reinstall my system a couple of times over the years and I have been annoyed at having to lose my several hundred clipboard entries each time. I know this topic is a couple of years old, but is there any chance of this being added to the Klipper GUI?

1 Like

@ajgringo619, does that cope with multimedia? I was expecting to see at least base-64 string representations of images with accompanying IANA Media Types, but I don’t appear to. Instead, I appear to merely see a string representation of a file: (schema-prefixed) URI.