#!/bin/bash outpath="$HOME/Pictures/Rewind" mkdir -p "$outpath" nDisplay=$(system_profiler SPDisplaysDataType | grep -c Resolution) ts=$(date +%Y%m%d%H%M%S) # Detect whether ocrmypdf is installed if ! command -v ocrmypdf &>/dev/null; then echo "ocrmypdf could not be found" exit else omp=$(command -v ocrmypdf) fi # Capture screenshots echo "Capturing at $ts" capture=$( for ((i = 1; i <= nDisplay; i++)); do echo "$outpath/capture.$ts.$i.pdf" done ) echo "$capture" | xargs screencapture -x -t pdf 2>&1 && echo "Captured" # OCR output files for ((i = 1; i <= nDisplay; i++)); do taskpolicy -b\ "$omp" "$outpath/capture.$ts.$i.pdf" "$outpath/capture.$ts.$i.pdf" \ -l chi_sim+eng\ --output-type pdf\ --optimize 3 done