dotfiles/.local/bin/print_slides

32 lines
1.3 KiB
Plaintext
Raw Normal View History

2022-11-14 10:00:29 +01:00
#!/bin/bash
# install cups-pdf and install printer using the webinterface on http://localhost:631/admin
# default virtual printer dir is below, adjust if changed
2022-11-15 09:02:55 +01:00
VIRTUAL_PRINTER_DIR="/var/spool/cups-pdf/$USER"
2022-11-14 10:00:29 +01:00
# Printer to print magazine layout on
PRINTER="Canon-MF220"
2024-03-09 13:38:38 +01:00
#PRINTER=Virtual_PDF_Printer
file="$1"
2023-10-12 15:12:12 +02:00
lpr -P Virtual_PDF_Printer -o number-up=2 -o orientation-requested=4 -o fit-to-page -o media=a4 "$file"
str="."
until lpc status | grep -A 4 'Virtual_PDF_Printer:' | tail -n1 | grep 'no entries'; do
printf "\033[s\033[uPrinting to file for two slides per a5 page"
printf "%s" $str
printf "\033[u"
str=$str.
sleep 1
2022-11-14 10:00:29 +01:00
done
2023-10-12 15:12:12 +02:00
echo "virtual printing done."
last_job_id="$(ls "$VIRTUAL_PRINTER_DIR" | grep -o '[0-9]*\.pdf$' | grep '[0-9]' | cut -d'.' -f1 | sort -n | tail -n1)"
#echo "last_job_id:$last_job_id"
file_two_page="$(ls $VIRTUAL_PRINTER_DIR/*${last_job_id}.pdf)"
#echo "file_two_page:$file_two_page"
printf "Invoking a5ona4..."
a5ona4 "$file_two_page" > /dev/null
echo "Done."
rm "$file_two_page"
only_filename_two_page="$( echo "$file_two_page"| awk -F/ '{print $NS}' )"
echo "Magazine layout of $file being sent to printer..."
file_without_suffix="$(echo "$file" | sed 's/[ \(\)]/_/g; s/\.pdf$//')"
lpr -P $PRINTER -o media=A4 -o Duplex=DuplexTumble -o sides=two-sided-short-edge -o BindEdge=Bottom -o media=a4 -r a5ona4_${file_without_suffix}*