create headless_homebrew_pdf.sh for local use

This commit is contained in:
Bel LaPointe
2023-10-19 10:17:40 -06:00
parent 8e119c59e0
commit 7ca8071baf
3 changed files with 38 additions and 29 deletions

36
headless_homebrew_pdf.sh Normal file
View File

@@ -0,0 +1,36 @@
#! /bin/sh
set -o pipefail
set -e
set -u
cd src
echo PRINTING PDF
echo ...which google
which google-chrome-stable
echo ...which miniserve
which miniserve
miniserve ./homebrew/ &
pid=${!}
until curl localhost:8080; do sleep 5; done
google-chrome-stable \
--no-sandbox \
--headless \
--disable-gpu \
--print-to-pdf=./homebrew/homebrew.pdf \
--run-all-compositor-stages-before-draw \
--no-pdf-header-footer \
http://localhost:8080/homebrew.html
get_state() {
cksum ./homebrew/homebrew.pdf | awk '{print $1}'
}
state=$(get_state)
while true; do
sleep 5
if [ "$state" == "$(get_state)" ]; then
break
fi
done
kill $pid || true
echo