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?
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
xmouspos package from xautomation
xdotoolcan get you the cursor’s coordinates (usingxdotool getmouselocation), but I am unsure how you would check whether that’s above a link. What do you mean ‘above a folder’? That could be a directory icon in a GUI file manager, a word in a terminal, or a dozen other things, as I see it.