ac875c07b1f05e5194c98361f70cef83b20cfb47
3 # Get screenshots from bow, discard them if they dont change much.
5 [[ $EUID == 0 ]] ||
exec sudo
-E "${BASH_SOURCE[0]}" "$@"
7 set -e; .
/usr
/local
/lib
/bash-bear
; set +e
16 f
=/run
/user
/1000/ziva-tmp.jpg
18 install -g 1000 -o 1000 -m 700 $dest_dir
22 if (( ${#jpgs[@]} >= 1 )); then
23 # shellcheck disable=SC2012 # this is much sorter than find|sort
24 lastf
=$
(ls -1 20*jpg |
tail -n1)
27 ssh bow DISPLAY
=:0 scrot
-z $f 2>/dev
/null ||
exit 0
28 rsync
--inplace bow
:$f $dest_dir 2>/dev
/null ||
exit 0
33 # returns 2 on error, but maybe in that case we want to ignore, file the image away
34 # and then it can go away in a subsequent comparison. going with that for now.
35 diff=$
(compare
-metric MSE
$lastf ziva-tmp.jpg
/dev
/null |
& sed 's/[^0-9].*//') ||
:
36 if printf "%s\n" "$diff" |
grep -E '^[0-9]+$' &>/dev
/null
&& (( diff < 200 )); then
44 mv ziva-tmp.jpg
"$(date +%F.%R)".jpg