You are not logged in.
Howdy, y'all!
Basically the title. I got a new keyboard with fewer keys and I keep accidentally pasting stuff. I know this kind of thing exists for X11, but I'd rather not rip out my sway config for i3 at this time. The Arch Wiki page itself lists a bunch of lightweight clipboard managers, which is great and all, but not what I am looking for. I'm not looking for anything too verbose; just automatic clearing after 10 seconds or, ideally, one paste would be ideal.
Also, if wl-clipboard has the functionality I am looking for, that would be ideal, and I want to hear about it.
Thanks!
Last edited by doctordeity (2026-04-27 07:35:56)
“Humans cannot create anything out of nothingness. Humans cannot accomplish anything without holding onto something. After all, humans are not gods.”
– Kaworu Nagisa
Offline
if wl-clipboard has the functionality I am looking for, that would be ideal
Tested to use -w to bump a timer that triggers -c ?
(Where "bumping" would just mean to fork a subshell routine and kill the previous one unless you're writing eg. a python script or so)
Offline
I have not. How do I set that as the default behaviour? Is there a config file? I see on the man page that there is /etc/mime.types but I don't see where I can set that there.
Also, how do I set a timer that will be read by wl-paste?
Last edited by doctordeity (2026-04-25 22:25:02)
“Humans cannot create anything out of nothingness. Humans cannot accomplish anything without holding onto something. After all, humans are not gods.”
– Kaworu Nagisa
Offline
You can use wl-paste --watch to execute a command every time something new is inserted into the clipboard. That command can then clear your clipboard.
For example,
wl-paste --watch sh -c "sleep 10; wl-copy --clear"will do the trick and you can put it in your WM config or as a systemd service.
Offline
@stag, will wl-paste thread-off or implicitly fork the command so it can handle events during the sleep?
Will it kill the running thread/process if there's a new clipboard event?
What happens if you ctrl+c and then ctrl+c again after 9 seconds, when will the clipboard be cleared?
Offline
Before I forget about this thread
#!/bin/bash
SLEEP_PID=0
nap_on() {
printf "restart "; date
(($SLEEP_PID)) && kill $SLEEP_PID
sleep 10 &
SLEEP_PID=$!
wait $SLEEP_PID || return
SLEEP_PID=0
printf "fire "; date
}
trap "nap_on" USR2
while true; do sleep 1; doneOffline
wl-paste runs the command synchrously without forking it off, it will wait for the sleep to finish before handling new commands. Since it doesn't fork killing it will clean everything up as expected, and if you copy something and copy something else after 9 seconds, at the 10th second the clipboard will be cleared.
To work around that you can fork off a subshell and store it's PID in a file, then kill it on subsequent events. I have not tested this but I believe it should work.
wl-paste --watch sh -c 'f="$XDG_RUNTIME_DIR/cb-clear.pid"; kill `cat "$f"`; [ "$CLIPBOARD_STATE" != "clear" ] && { (sleep 10; wl-copy --clear) & echo $! > "$f"; }'Last edited by stag (2026-04-26 20:30:46)
Offline
Thank you all so much! The last solution worked for me.
“Humans cannot create anything out of nothingness. Humans cannot accomplish anything without holding onto something. After all, humans are not gods.”
– Kaworu Nagisa
Offline