You are not logged in.

#1 2026-04-25 00:49:15

doctordeity
Member
From: behind you
Registered: 2020-05-18
Posts: 12

[SOLVED] Clipboard Manager for Wayland with Automatic Clearing

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

#2 2026-04-25 11:14:35

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,855

Re: [SOLVED] Clipboard Manager for Wayland with Automatic Clearing

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

#3 2026-04-25 21:49:32

doctordeity
Member
From: behind you
Registered: 2020-05-18
Posts: 12

Re: [SOLVED] Clipboard Manager for Wayland with Automatic Clearing

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

#4 2026-04-26 01:13:44

stag
Member
From: new york
Registered: 2026-04-26
Posts: 2
Website

Re: [SOLVED] Clipboard Manager for Wayland with Automatic Clearing

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

#5 2026-04-26 08:02:23

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,855

Re: [SOLVED] Clipboard Manager for Wayland with Automatic Clearing

@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

#6 2026-04-26 18:38:36

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,855

Re: [SOLVED] Clipboard Manager for Wayland with Automatic Clearing

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; done

Offline

#7 2026-04-26 20:30:32

stag
Member
From: new york
Registered: 2026-04-26
Posts: 2
Website

Re: [SOLVED] Clipboard Manager for Wayland with Automatic Clearing

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

#8 2026-04-27 07:34:17

doctordeity
Member
From: behind you
Registered: 2020-05-18
Posts: 12

Re: [SOLVED] Clipboard Manager for Wayland with Automatic Clearing

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

Board footer

Powered by FluxBB