| 1 | #! /bin/sh -e |
| 2 | |
| 3 | case $# in 1) ;; *) echo >&2 "usage: $1 ZOOM"; exit 2 ;; esac |
| 4 | zoom=$1 |
| 5 | |
| 6 | ok=nil |
| 7 | case $zoom in |
| 8 | */*/*) ;; |
| 9 | *[!0-9/]*) ;; |
| 10 | */*) ok=t mul=${zoom%/*} div=${zoom#*/} ;; |
| 11 | *) ok=t mul=1 div=$zoom ;; |
| 12 | esac |
| 13 | case $ok in nil) echo >&2 "$0: bad zoom $zoom"; exit 2 ;; esac |
| 14 | case $(( $mul > $div )) in 1) echo >&2 "$0: zoom too high"; exit 2 ;; esac |
| 15 | |
| 16 | ok=nil |
| 17 | case ${DISPLAY-nil} in |
| 18 | *:*[!0-9.]*) ;; |
| 19 | *:*.*.*) ;; |
| 20 | *:*.*) ok=t dpybase=${DISPLAY%.*} ;; |
| 21 | *:*) ok=t dpybase=$DISPLAY ;; |
| 22 | esac |
| 23 | case $ok in nil) echo >&2 "$0: bad DISPLAY"; exit 2 ;; esac |
| 24 | |
| 25 | set -- $(xqueryptr); scr=$1 x=$2 y=$3 |
| 26 | DISPLAY=$dpybase.$scr; export DISPLAY |
| 27 | |
| 28 | eval $(xscsize -b) |
| 29 | |
| 30 | case $(( $XWIDTH%$div || $XHEIGHT%$div )) in |
| 31 | 0) ;; |
| 32 | *) echo >&2 "$0: zoom divisor doesn't divide screen size"; exit 2 ;; |
| 33 | esac |
| 34 | |
| 35 | { read _ |
| 36 | found=nil |
| 37 | while read _ _ respos name; do |
| 38 | res=${respos%%+*} pos=${respos#*+} |
| 39 | ww=${res%x*} hh=${res#*x} |
| 40 | w=${ww%/*} h=${hh%/*} |
| 41 | x0=${pos%+*} y0=${pos#*+} |
| 42 | x1=$(( $x0 + $w )) y1=$(( $y0 + $h )) |
| 43 | case $(( $x0 <= $x && $x < $x1 && $y0 <= $y && $y < $y1 )) in |
| 44 | 1) found=t; break ;; |
| 45 | esac |
| 46 | done |
| 47 | } <<EOF |
| 48 | $(xrandr --listmonitors) |
| 49 | EOF |
| 50 | |
| 51 | case $found in nil) echo >&2 "$0: pointer not on any screen?"; exit 2 ;; esac |
| 52 | |
| 53 | case $(( $mul == $div )) in |
| 54 | 1) pan= ;; |
| 55 | *) pan="--panning ${XWIDTH}x${XHEIGHT}" ;; |
| 56 | esac |
| 57 | |
| 58 | xrandr --fb ${XWIDTH}x${XHEIGHT} \ |
| 59 | --output $name \ |
| 60 | --mode $(( $mul*$XWIDTH/$div ))x$(( $mul*$XHEIGHT/$div )) \ |
| 61 | $pan |