The modern clipboard manager has a history feature that lets you select past entries to re-paste them anywhere. However, this history can hold up to a certain number of entries. When it reaches a point, it will start to discard the oldest. To keep some clipboard entries for future reference, you must bring them back to the active clipboard slot and enter them one by one in some note-taking applications.
Here’s a clever “hack” to back up your clipboard history to a plain text file in a folder of your choice.
note:: Although we used the clipboard widget of the KDE desktop in this tutorial, you can do the same in any clipboard manager that supports user-added operations such as Clipman.
To use the clipboard widget, you must first place it on your desktop. Click the KDE main menu button at the top right of the screen and select “Add Widget” from the pop-up menu.
KDE will show you its collection of widgets in a pane on the left side of the screen.
Scroll down until you find a clipboard entry, or start typing “Clipboard” in the text field at the top of the pane to filter the list.
Once you find the Clipboard widget, drag and drop it where you want it to appear on your desktop.
From this configuration window, move to the Actions tab and click the Add Action button.
In the new Action Properties window that appears, leave Regular Expression blank and enable Automatic. Enter a short description of your action in the Description field.
Before adding the actual command, it’s a good idea to launch the terminal and test it before committing completely.
Adjust date output
The command itself will contain two separate subcommands / actions. We will use the current time as the file name for each note.
For this we will assign
date The command is added to the “NOW” variable. We won’t go into the details of the date command. To learn more, enter
man date Either
date --help In one terminal.
In our example, we want the file name to look like “Hours-Minutes-Seconds__Month-Day-Year.txt”, so we set the variable to:
Add note path
The second action in the command “dumps” the selected entry into a text file with the variable “NOW” as its file name. We use trusted
echo "%s" > /home/USERNAME/Desktop/$NOW.txt
%s The bits are provided by the widget itself and are mapped to the selected clipboard entry. The second part specifies the path and file name of the saved comment.
To make testing easier, we put clipboard notes on the desktop when setting up this solution. If you don’t like the situation where the desktop is full of text files, we recommend that you modify this path to another path at least after the initial test.
The full final version of the command looks like this:
NOW=$(date +"%H-%M-%S__%m-%d-%Y") && echo "%s" > /home/USERNAME/Desktop/$NOW.txt
Click the Add Command button to create a new command, then double-click the New Command placeholder for editing.
Replace it with your own command (or copy and paste our command) and click OK to accept the changes and enable it.
If you don’t want the command to appear without a name in the clipboard widget, add a description for it.
Click OK, your changes will be applied, and when you return to the Action Configuration window, you will see your creation in the Action List.
check it out
To check your new actions, click the clipboard widget after copying some text to the clipboard.
When you hover your mouse over an entry, the clipboard widget displays a small menu on its right side, and its first entry is “Call Action”. Click the menu to access your custom actions.
Select your custom action from the pop-up entries that appear.
That’s it: if everything goes according to plan, and you test using the desktop path like we did, you will see the first note on the desktop. From now on, you will be able to use the custom actions you created to back up your clipboard history.
Two closing tips: First, make sure you always include seconds in the file name. This way, if you take notes in the same minute, they won’t have to fight for the same file name. Second, to make this more convenient, use the folder in your favorite cloud sync service as a path to make clipboard notes everywhere.