Bug 185311 - Option to auto erase content after a certain amount of time
Summary: Option to auto erase content after a certain amount of time
Status: RESOLVED INTENTIONAL
Alias: None
Product: plasmashell
Classification: Plasma
Component: Clipboard widget & pop-up (other bugs)
Version First Reported In: 5.15.3
Platform: Gentoo Packages Unspecified
: NOR wishlist
Target Milestone: 1.0
Assignee: Esben Mose Hansen
URL:
Keywords:
: 351659 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-02-23 10:07 UTC by Atle
Modified: 2025-10-01 15:57 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
script to clear kde/klipper clipboard after n seconds of last 'copy' action (1.13 KB, text/plain)
2023-03-02 22:07 UTC, Mike
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Atle 2009-02-23 10:07:51 UTC
Version:            (using KDE 4.2.0)
Installed from:    Gentoo Packages

Hi,

I use klipper for cutting and pasting passwords all of the time. This is not very secure if someone else stops by my computer.

I'd like an option to auto erase clipboard entries that are older than N seconds. Usually the content is needed within a very few seconds anyway.

Different settings for clipboard and selection would be nice.

Another nice feature would be the ability to lock certain items in the clipboard. Maybe even save it so that it's there next time KDE i started.

Keep up the good work.

Atle
Comment 1 Jekyll Wu 2011-12-28 05:50:23 UTC
I think "saving password in some file for copying later" is insecure by nature. Klipper just increases the chance that other see your password accidentally.

> Usually the content is needed within a very few seconds anyway.

For this password case, it is true. But for general cases, that 'auto erasing' feature  is essentially against the goal of Klipper: track the clipboard history for later use. I know many users set large size for the clipboard history, and they probably won't like or be interested with this option.

An possible solution for this password problem is allow users to delete some history item manually, for example, by pressing the 'Delete' key on it.
Comment 2 Nate Graham 2021-04-01 21:07:04 UTC
*** Bug 351659 has been marked as a duplicate of this bug. ***
Comment 3 Mike 2023-03-02 22:07:18 UTC
Created attachment 156935 [details]
script to clear kde/klipper clipboard after n seconds of last 'copy' action
Comment 4 Mike 2023-03-02 22:08:54 UTC
I would like to see this request revisited. 

With the popularity of password managers and the increasing use of pseudorandom strings as identifiers for things like crypto wallets, the clipboard is increasingly used to hold highly sensitive information. This has also been a lure for malicious actors. And while the overwhelming majority, of those malicious actors target Windows users, I would prefer we not become victims of our own hubris :)

Currently I manage this with a script that runs from .config/autostart and checks org.kde.klipper.klipper.getClipboardContents once per minute. Then, when extant data in the clipboard is unchanged for >10 minutes, it runs clearClipboardHistory.

A more perfect (for me) solution would watch for clipboard activity (copy AND paste), then clear the contents if there is no activity for x seconds.

Seeing a check box for "Automatically clear clipboard history when inactive?" and a box to specify how many seconds after the last copy/paste action to wait near 'Clipboard history' in the Klipper configuration applet seems to make perfect sense. :) 

(In reply to Mike from comment #3)
> Created attachment 156935 [details]
> script to clear kde/klipper clipboard after n seconds of last 'copy' action
Comment 5 htpha 2023-10-23 19:39:07 UTC
(In reply to Mike from comment #4)
> Currently I manage this with a script that runs from .config/autostart and
> checks org.kde.klipper.klipper.getClipboardContents once per minute. Then,
> when extant data in the clipboard is unchanged for >10 minutes, it runs
> clearClipboardHistory.
> 
> A more perfect (for me) solution would watch for clipboard activity (copy
> AND paste), then clear the contents if there is no activity for x seconds.

Hi!
I might have a solution/workaround for you :^)

I was working on a solution to open mpv on copying youtube urls. I am using Klippers Action Menu for this to pass all urls matching my pattern to mpv but this will clutter Klipper with youtube links after a while. Therefore I wanted these Klipper entries to be removed on triggering my Klipper action. If you suppress the output of your command or your command doesn't write to stdout and select "Replace current clipboard" for "Output from command:" this entry will be removed from Klippers list.

So here is something you can try:

1. Create a new Klipper Action: Configure Clipboard > Actions Configuration > Add Action
2. Action Properties: Enter your regex pattern and description, ie. "Clear clipboard history in ... secs after this copy" > Add Command
3. Command Properties: Command: sleep $YOUR_X_SECS && qdbus org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory
4. Command Properties: Output from command: Replace current clipboard (if you want this specific entry to be deleted instead of whole history)
4. ??
5. Profit

With this you have control over when the history should be cleared instead of relying on a timer. In my case only entries I want to be removed will be affected and everything else stays. I don't use any delay, only surpressing mpv's output is enough. You can do something similar for anything you don't want to stay in the history. Name the Action something like "Delete this in 10secs" and as Command only use sleep.

I also ticked "Show action popup menu:" to "Immediately on selection" or you can press your shortcut to trigger the Action menu. I believe Meta+Ctrl+R is the default.

At nate@kde.org: what is the purpose of org.kde.klipper.klipper.clearClipboardContents? It doesn't seem to do anything..
Comment 6 Niccolò Venerandi 2025-09-30 12:49:50 UTC
Sounds like a solution was provided? Also the ability to lock certain items was recently implemented too.
Comment 7 Mike 2025-10-01 15:57:30 UTC
(In reply to Niccolò Venerandi from comment #6)
> Sounds like a solution was provided? Also the ability to lock certain items
> was recently implemented too.

These are workarounds. Workarounds are not solutions to a feature request.