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