Skip to content

Instantly share code, notes, and snippets.

@dangle
Created September 24, 2020 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dangle/eeb3e300263932672f3f46bb0c5bfade to your computer and use it in GitHub Desktop.
Save dangle/eeb3e300263932672f3f46bb0c5bfade to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
IFS=$'\n'
eval $(xdotool getmouselocation --shell --prefix "MOUSE_")
for monitor in $(herbstclient list_monitors)
do
eval $(awk '{
print "ID=" $1
print "W=" $2
print "H=" $3
print "X=" $4
print "Y=" $5
}' <<< $(
awk '{
gsub(/:/, "", $1)
gsub(/x|+/, " ", $2)
print $1 " " $2
}' <<< ${monitor}
))
if (( $MOUSE_X >= $X && $MOUSE_X < $X + $W
&& $MOUSE_Y >= $Y && $MOUSE_Y < $Y + $H ))
then
echo $ID
break
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment