Skip to main content

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Asked
Modified 10 months ago
Viewed 133 times
3

I know that the clipboard is not a function of the Linux kernel but a feature of the desktop. And there is no "location" where the content in the clipboard is saved. Clipboard is saved in RAM.

Is there a way to run a script every time the clipboard is changed? The only way I know is to run a infinite loop, something like this:

while true; do
 var1=$(xclip -selection clipboard -o)
 sleep 0.5
 var2=$(xclip -selection clipboard -o)
 if [ "$var1" != "$var2" ]; then
  make crazy sh*t
 fi
done

Is this the only way?

1
  • I'm thinking that your question could maybe be considered a duplicate of Getting notified about clipboard content changes. Certainly seems like the simple program mentioned in @justpeanuts answer would solve your problem.
    David Yockey
    –  David Yockey
    2024-11-22 02:20:05 +00:00
    Commented Nov 22, 2024 at 2:20

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.