Be notified on clipboard read or write #88

Open
opened 2025-08-06 16:14:21 +02:00 by Benjamin_Loison · 11 comments
Related to [Benjamin_Loison/firefox/issues/188](https://codeberg.org/Benjamin_Loison/firefox/issues/188).
Author
Owner

Could be useful when having a bad Internet connection, but want to download many YouTube videos from Element by putting each into clipboard.

DuckDuckGo search Debian be notified on clipboard change.

Could be useful when having a bad Internet connection, but want to download many YouTube videos from Element by putting each into clipboard. DuckDuckGo search *Debian be notified on clipboard change*.
Author
Owner

The Unix Stack Exchange answer 723818:

clipnotify has 242 stars and last commit was 3 years ago.

clipnotify/tree/25ba143c7da8ae0f196cb0db2797d30e6d04e15c seems to indeed not be poll based as states README.md.

[The Unix Stack Exchange answer 723818](https://unix.stackexchange.com/a/723818): [clipnotify](https://github.com/cdown/clipnotify) has 242 stars and last commit was 3 years ago. [clipnotify/tree/25ba143c7da8ae0f196cb0db2797d30e6d04e15c](https://github.com/cdown/clipnotify/tree/25ba143c7da8ae0f196cb0db2797d30e6d04e15c) seems to indeed not be poll based as states `README.md`.
Author
Owner
Related to [Benjamin-Loison/gitea/issues/122](https://github.com/Benjamin-Loison/gitea/issues/122).
Author
Owner
make
cc   clipnotify.c -o clipnotify -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lXfixes
``` make ``` ``` cc clipnotify.c -o clipnotify -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lXfixes ```
Author
Owner

When double click a word in the terminal the program exits which is unwanted. It seems to also exit when ctrl + c on text editor which is a wanted behavior. Note that when the program exit there is still no output.

When double click a word in the terminal the program exits which is unwanted. It seems to also exit when <kbd>ctrl</kbd> + <kbd>c</kbd> on text editor which is a wanted behavior. Note that when the program exit there is still no output.
Author
Owner
./clipnotify --help
Output:
./clipnotify: invalid option -- '-'
./clipnotify: Notify by exiting on clipboard events.

  -l    Instead of exiting, print a newline when a new selection is available.
  -s    The selection to use. Available selections:
        clipboard, primary, secondary
        The default is to monitor clipboard and primary.
./clipnotify -h
Output:
./clipnotify: Notify by exiting on clipboard events.

  -l    Instead of exiting, print a newline when a new selection is available.
  -s    The selection to use. Available selections:
        clipboard, primary, secondary
        The default is to monitor clipboard and primary.
``` ./clipnotify --help ``` <details> <summary>Output:</summary> ``` ./clipnotify: invalid option -- '-' ./clipnotify: Notify by exiting on clipboard events. -l Instead of exiting, print a newline when a new selection is available. -s The selection to use. Available selections: clipboard, primary, secondary The default is to monitor clipboard and primary. ``` </details> ``` ./clipnotify -h ``` <details> <summary>Output:</summary> ``` ./clipnotify: Notify by exiting on clipboard events. -l Instead of exiting, print a newline when a new selection is available. -s The selection to use. Available selections: clipboard, primary, secondary The default is to monitor clipboard and primary. ``` </details>
Author
Owner

ctrl + v does not make the program exit, which is quite as wanted.

<kbd>ctrl</kbd> + <kbd>v</kbd> does not make the program exit, which is quite as wanted.
Author
Owner
./clipnotify -s clipboard

works as wanted, not stopping the program on word double clicked in the terminal.

It works fine even if the program is running in the background.

``` ./clipnotify -s clipboard ``` works as wanted, not stopping the program on word double clicked in the terminal. It works fine even if the program is running in the background.
Author
Owner

It correctly also exits if copy the same clipboard content.

It correctly also exits if copy the same clipboard content.
Author
Owner

-l works as wanted.

`-l` works as wanted.
Author
Owner
Bash script:
while ./clipnotify
do
    xclip -selection clipboard -out
    echo
done
Output:
https://www.youtube.com/watch?v=q1HVFlNtRJA
https://www.youtube.com/watch?v=_pCYKRhOyLE
https://www.youtube.com/watch?v=eXo0LkaddkQ
https://www.youtube.com/watch?v=8RCESw7GW3A
https://www.youtube.com/watch?v=6JgZ80-5hkE
https://www.youtube.com/watch?v=LXRq3sCtYPE

Note that for Element right-clicking a URL and enter proceeds to Copy link.

<details> <summary>Bash script:</summary> ```bash while ./clipnotify do xclip -selection clipboard -out echo done ``` </details> <details> <summary>Output:</summary> ``` https://www.youtube.com/watch?v=q1HVFlNtRJA https://www.youtube.com/watch?v=_pCYKRhOyLE https://www.youtube.com/watch?v=eXo0LkaddkQ https://www.youtube.com/watch?v=8RCESw7GW3A https://www.youtube.com/watch?v=6JgZ80-5hkE https://www.youtube.com/watch?v=LXRq3sCtYPE ``` </details> Note that for Element right-clicking a URL and <kbd>enter</kbd> proceeds to *Copy link*.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Benjamin_Loison/linux#88
No description provided.