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?
Asked by fmeier
(361 rep)
Nov 19, 2024, 04:50 PM
Last activity: Nov 20, 2024, 10:18 AM
Last activity: Nov 20, 2024, 10:18 AM