Last active
January 26, 2017 14:06
-
-
Save janvojt/4770149 to your computer and use it in GitHub Desktop.
Manual duplex printing wizard.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# author: Jan Vojt | |
# number of pages | |
nop= | |
while ! [[ "$nop" =~ ^[0-9]+$ ]]; do | |
echo -n "Total number of pages in document: " | |
read nop | |
done; | |
# pages per paper side -> 2*ppp pages per paper | |
ppp= | |
while ! [[ "$ppp" =~ ^[1246]$ ]]; do | |
echo -n "Pages per paper side to print: " | |
read ppp | |
done; | |
# correct naming according to printing setup | |
if [ $ppp -gt 1 ]; then | |
page="sheet" | |
else | |
page="page" | |
fi | |
# calculate total number of paper sides needed for the job | |
rem=`expr $nop % $ppp` | |
if [ $rem -gt 0 ]; then | |
tot=`expr $nop / $ppp + 1` | |
else | |
tot=`expr $nop / $ppp` | |
fi | |
# calculate total number of papers needed for the job | |
rem=`expr $ppp \* 2` | |
rem=`expr $nop % $rem` | |
if [ $rem -gt 0 ]; then | |
totpapers=`expr $nop / $ppp / 2 + 1` | |
else | |
totpapers=`expr $nop / $ppp / 2` | |
fi | |
echo | |
echo "OK, let's start." | |
echo "You will need ${totpapers} blank papers in the input tray for the job." | |
echo | |
step=1; | |
echo "${step}. Print EVEN ${page}s in standard order." | |
echo -n "[OK]" | |
read | |
step=`expr $step + 1` | |
if [ $ppp -gt 1 ]; then | |
echo "${step}. Take printed papers out of the output tray, and place into the input tray exactly as they came out (do not change their orientation)." | |
else | |
echo "${step}. Take printed papers out of the output tray, turn them 180 degrees horizontally, and place into the input tray." | |
fi | |
echo -n "[OK]" | |
read | |
step=`expr $step + 1` | |
rem=`expr $tot % 2` | |
if [ $rem -eq 1 ]; then | |
echo "${step}. Put a single blank paper onto the other printed pages in input tray." | |
echo -n "[OK]" | |
read | |
step=`expr $step + 1` | |
fi | |
echo "${step}. Print ODD ${page}s in REVERSED order." | |
echo -n "[OK]" | |
read | |
echo "Enjoy your ordered printout you can find in output tray! ;)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment