rpi: настроить домашнюю печать на Brother DCP-L2620DW

This commit is contained in:
2026-10-11 15:18:56 +03:00
parent 4965f70299
commit 629b11f03f
4 changed files with 65 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
#!/bin/sh
# Usage: home-print status | home-print [--duplex] FILE.pdf|FILE.png|FILE.jpg
set -eu
printer=home-brother
if [ "${1:-}" = status ]; then
lpstat -p "$printer"
lpstat -W not-completed -o "$printer"
exit
fi
sides=one-sided
if [ "${1:-}" = --duplex ]; then
sides=two-sided-long-edge
shift
fi
if [ "$#" -ne 1 ] || [ ! -f "$1" ]; then
echo 'Укажите один существующий PDF/PNG/JPEG-файл' >&2
exit 2
fi
case "$1" in
*.pdf|*.PDF|*.png|*.PNG|*.jpg|*.JPG|*.jpeg|*.JPEG) ;;
*) echo 'Поддерживаются PDF/PNG/JPEG; Word сначала преобразуйте в PDF' >&2; exit 2 ;;
esac
# Absolute path prevents a filename from becoming an lp option.
file=$(realpath -- "$1")
exec lp -d "$printer" -n 1 -o media=A4 -o fit-to-page -o sides="$sides" "$file"