Add printer scripts
This commit is contained in:
parent
8c950a02ea
commit
781a02dce6
29
printer/scripts/convert.sh
Executable file
29
printer/scripts/convert.sh
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source shared.sh
|
||||||
|
|
||||||
|
if [ "$1" == "" ]; then
|
||||||
|
echo "usage: $0 <file>"
|
||||||
|
exit;
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p out
|
||||||
|
rm out/*
|
||||||
|
|
||||||
|
echo ".ll $LL" > out/header
|
||||||
|
cat "$1" | sed 's/\./\\\&./g' > out/text
|
||||||
|
echo ".sp 0" > out/footer
|
||||||
|
cat out/header out/text out/footer | nroff -Tascii > out/render
|
||||||
|
|
||||||
|
cline=0
|
||||||
|
page=1
|
||||||
|
while IFS="" read -r p || [ -n "$p" ]
|
||||||
|
do
|
||||||
|
cline=$(($cline + 1))
|
||||||
|
if [ $cline -eq $PL ]; then
|
||||||
|
page=$(($page + 1))
|
||||||
|
cline=0
|
||||||
|
fi
|
||||||
|
printf '%s\n' "$p" >> "out/out$page.txt"
|
||||||
|
done < out/render
|
||||||
|
|
||||||
|
echo "Created $page pages."
|
39
printer/scripts/print.sh
Executable file
39
printer/scripts/print.sh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source shared.sh
|
||||||
|
|
||||||
|
ML=$(( (110-$LL) / 2))
|
||||||
|
MT=$(( (64 - $PL) / 2 ))
|
||||||
|
echo "Margin left: $ML"
|
||||||
|
echo "Margin top : $MT"
|
||||||
|
echo "Page width : $LL"
|
||||||
|
echo "Page length: $PL"
|
||||||
|
|
||||||
|
if [ $MT -gt 127 ]; then
|
||||||
|
echo "Margin top > 127 not supported because I am lazy. Is $MT."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
MT=$(( $MT + 128 )) # Set "move by n line bit"
|
||||||
|
#exit
|
||||||
|
echo -ne $(printf "\\\\x%02x\\\\x%02x" 224 $ML) > /dev/lw35
|
||||||
|
MR=$((ML + $LL + 2)); # Plus 2 because bug in FW in conjunction with manual newlines
|
||||||
|
echo -ne $(printf "\\\\x%02x\\\\x%02x" 225 $MR) > /dev/lw35
|
||||||
|
|
||||||
|
for file in ./out/out*; do
|
||||||
|
foo=""
|
||||||
|
while [ true ]; do
|
||||||
|
echo "Insert a piece of paper and press enter. When you're done, enter y."
|
||||||
|
read foo
|
||||||
|
if [ "$foo" == "y" ]; then
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
echo -ne "\xE3\x8C" > /dev/lw35 # Draw in until at top of paper
|
||||||
|
echo -ne $(printf "\\\\x%02x\\\\x%02x" 0xE3 $MT) > /dev/lw35 # Move over margin top
|
||||||
|
done
|
||||||
|
echo "Printing part $file..."
|
||||||
|
|
||||||
|
cat $file > /dev/lw35
|
||||||
|
echo "Part done."
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Done."
|
6
printer/scripts/shared.sh
Executable file
6
printer/scripts/shared.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Limits for A4 vertical
|
||||||
|
LL=80 # Max 90
|
||||||
|
PL=58 # Max 64
|
||||||
|
|
Loading…
Reference in New Issue
Block a user