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