I'm trying to make a bash script that requires the ability to probe the cursor state, e.g. if it's hovering over a link or a document I need it to behave differently than if it's neutral or hovering text.
How could I go about doing this?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Getting the coordinates of mouse pointer.
Below is the script and configuring a keyboard shortcut to run it, we can copy mouse coordinates to the clipboard in x,y format. Here's how:
sudo apt-get install xdotool xsel
#!/bin/bash xdotool getmouselocation | grep -oP "[0-9]+ y:[0-9]+" | sed 's/ y:/,/' | tr -d '\n' | xsel --clipboard