-
-
Save jD91mZM2/99cfe5e74e34a08f4b0854c82f9bc0b3 to your computer and use it in GitHub Desktop.
Just screenshots the monitor that the mouse is on.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
monitors="$(xrandr | grep -o '[0-9]*x[0-9]*[+-][0-9]*[+-][0-9]*')" | |
# Get the location of the mouse | |
eval "$(xdotool getmouselocation --shell --prefix mouse_)" | |
while read -r line; do | |
if [[ "$line" =~ ([0-9]+)x([0-9]+)([+-][0-9]+)([+-][0-9]+) ]]; then | |
specs="${BASH_REMATCH[0]}" | |
width="${BASH_REMATCH[1]}" | |
height="${BASH_REMATCH[2]}" | |
x="${BASH_REMATCH[3]}" | |
y="${BASH_REMATCH[4]}" | |
echo "$width * $height + $offset_x + $offset_y" | |
if (( $mouse_X >= $x )) && (( $mouse_X <= $x+$width )) \ | |
&& (( $mouse_Y >= $y )) && (( $mouse_Y <= $y+$height )); then | |
import -window root -crop "$specs" /tmp/screenshot.png | |
break | |
fi | |
fi | |
done < <(xrandr) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment