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?