add pagetest.sh: generate a page-break diagnostic printout
Numbered, fixed-width lines let us read a printer's actual page length and line width limits straight off the paper, instead of guessing them from A4 geometry - needed to nail down the real constants for the PRINTER_A4 landscape math. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>master
parent
c9cf7f6484
commit
796b1c4830
|
|
@ -0,0 +1,34 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Generates a page-break diagnostic file: numbered lines padded with '#' to
|
||||||
|
# a fixed width, so you can see exactly where a printer's real page length
|
||||||
|
# and line width limits are instead of guessing from paper geometry.
|
||||||
|
#
|
||||||
|
# Usage: ./pagetest.sh [width] [lines]
|
||||||
|
# width - characters per line, including the "NNN " prefix (default 64)
|
||||||
|
# lines - number of lines to generate (default 100)
|
||||||
|
#
|
||||||
|
# Print the result with PRINTER_A4=false in printer.conf (no rotation), so
|
||||||
|
# the line numbers read straight off the page:
|
||||||
|
# ./txt2printr.sh pagetest.txt
|
||||||
|
|
||||||
|
dir="$(dirname "$0")"
|
||||||
|
width="${1:-64}"
|
||||||
|
lines="${2:-100}"
|
||||||
|
outfile="$dir/pagetest.txt"
|
||||||
|
|
||||||
|
awk -v width="$width" -v lines="$lines" '
|
||||||
|
BEGIN {
|
||||||
|
for (i = 1; i <= lines; i++) {
|
||||||
|
prefix = sprintf("%03d ", i)
|
||||||
|
fill = width - length(prefix)
|
||||||
|
if (fill < 0) fill = 0
|
||||||
|
line = prefix
|
||||||
|
for (j = 0; j < fill; j++) line = line "#"
|
||||||
|
print line
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' > "$outfile"
|
||||||
|
|
||||||
|
echo "Wrote $lines lines x $width chars to $outfile"
|
||||||
|
echo "Print it with: PRINTER_DEV=/dev/lp0 \"$dir/txt2printr.sh\" \"$outfile\""
|
||||||
Loading…
Reference in New Issue