From c89e1e01acf07c773a59889df26bce873d54c127 Mon Sep 17 00:00:00 2001 From: The_miro Date: Tue, 14 Jul 2026 08:57:56 +0200 Subject: [PATCH] added more options for printers - if none fount it should output to stdout --- txt2printr.sh | 19 ++++++++++++++++++- v | 0 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 v diff --git a/txt2printr.sh b/txt2printr.sh index 99f6a45..c790fda 100755 --- a/txt2printr.sh +++ b/txt2printr.sh @@ -6,7 +6,24 @@ # Env: PRINTER_DEV - printer device node (default: /dev/lp0) infile="${1:-ascii-img.txt}" -dev="${PRINTER_DEV:-/dev/lp0}" +# Source - https://stackoverflow.com/a/638980 +# Posted by John Feminella, modified by community. See post 'Timeline' for change history +# Retrieved 2026-07-14, License - CC BY-SA 4.0 + +if [ -f /dev/lp0 ]; then + dev="${PRINTER_DEV:-/dev/lp0}" +fi + +if [ -f /dev/usb/lp0 ]; then + dev="${PRINTER_DEV:-/dev/usb/lp0}" +fi + + +if [ ( ! -f /dev/lp0 ) && ( ! -f /dev/usb/lp0 )]; then + dev="${PRINTER_DEV:-/dev/stdout}" +fi + + if [ ! -f "$infile" ]; then echo "txt2printr: file not found: $infile" >&2 diff --git a/v b/v new file mode 100644 index 0000000..e69de29