This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Export all clips from Klipper to plain text file

Tags: None
(comma "," separated)
iembry
Registered Member
Posts
2
Karma
0
Greetings, I was not able to save a file opened in Kate when my laptop shutdown due to a completely drained battery. I had been copying and pasting a lot of text in the Kate text file using Klipper. I can access the .lst file from Klipper, but I can't view any of the saved clips as plaintext.

1) Is there a way to view the.lst file as plaintext in a text editor?

2) If not, then is there a way to export all Klipper entries to a text file using the command line (BASH), Python script, etc.?

Thank you.

Irucka
budimansnowman
Registered Member
Posts
2
Karma
0
Yes, I find it strange too that Kilpper does not provide an easy way to get or export or paste all entries (I have read the handbook and searched this forum and couldn't find a solution either).

I thought this is one of the basic use-case of Klipper as a multiclipboard tool. Instead of copy-pasting multiple entries (e.g. links of YouTube videos) one by one to a text editor, you can just copy-copy-copy the links to store on Klipper and later on paste all the copied links in one go to the text editor.
koffeinfriedhof
Registered Member
Posts
608
Karma
4
OS
Hi!

You could use the dbus-methods provides by klipper. To get every entry, do something like
Code: Select all
#!/bin/bash
n=1  # the list postition counter (messages counter)
f="I am the placeholder for each line in klipper"  # must not be "" !
while [ 1 ]; do
   f="$(qdbus org.kde.klipper /klipper getClipboardHistoryItem $n)" # query item number n
   if [ -z "$f" ]; then break; fi  # if "$f" has zero length (empty), stop
   echo "CLIP $n" "CONTENT: $f"  # printing to stdout, use printf to advances formatting
   n=$((++n))  # increase n
done


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell