#!/bin/bash [ -d $(xdg-user-dir PICTURES)/screenshots ] || mkdir -p $(xdg-user-dir PICTURES)/screenshots mx=$(xdotool getmouselocation | awk -F'[: ]' '{print $2}') my=$(xdotool getmouselocation | awk -F'[: ]' '{print $4}') xdpyinfo -ext XINERAMA | sed '/^ head #/!d;s///' | while IFS=' :x@,' read i w h x y; do if [[ $mx -ge $x && $mx -le $(($x + $w)) && $my -ge $y && $my -le $(($y + $h)) ]]; then import -window root -crop ${w}x$h+$x+$y "$(xdg-user-dir PICTURES)/screenshots/$(date +%F_%H%M%S_%N)-${i}.png" fi done