michaelrsweet / pappl

PAPPL - Printer Application Framework
https://www.msweet.org/pappl
Apache License 2.0
309 stars 49 forks source link

Add raw port option for server mainloop sub-command #187

Closed CyrosX closed 2 years ago

CyrosX commented 2 years ago

I just wanted to share my little setup shell script creation. This needs lprint to be installed already. I did this via apt & the Debian repositories on dietpi (7.7) - Raspberry Pi Zero W.

The script creates a 9100 + 9102 (JetDirect) stream accepting systemd socket & service for receiving raw printing data and a lprint-server service (%H is the hostname) This allows the additional usage of Dymo Connect on Windows. You need to create the printer connection and use the original drivers, else the printer/s won't appear in the label software. This wasn't working when I've tried to use IPP on Windows - on MacOS IPP works fine. I've only found xinet.d / inetd solutions on the internet.

Happy to hear suggestions for improvement :-).

cat >> /etc/systemd/system/lprint.service <<EOL
[Unit]
Description=lprint-server
Wants=network-online.target
After=network-online.target

[Service]
User=root
WorkingDirectory=/root
ExecStart=lprint server -o log-file=- -o log-level=debug -o server-port=8631 -o server-name=%H
ExecStop=lprint shutdown
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOL

cat >> /etc/systemd/system/dymo-450-label@.service <<EOL
[Unit]
Description=dymo-450-label-service
Requires=dymo-450-label.socket

[Service]
ExecStart=/usr/bin/lprint -d dymo-450-label -o raw
StandardInput=socket
StandardError=journal
TimeoutStopSec=5

[Install]
WantedBy=multi-user.target
EOL

cat >> /etc/systemd/system/dymo-450-label.socket <<EOL
[Unit]
Description=dymo-450-label-socket

[Socket]
ListenStream=9100
Accept=yes
NoDelay=true

[Install]
WantedBy=sockets.target
EOL

cat >> /etc/systemd/system/dymo-450-tape@.service <<EOL
[Unit]
Description=dymo-450-tape-service
Requires=dymo-450-tape.socket

[Service]
ExecStart=/usr/bin/lprint -d dymo-450-tape -o raw
StandardInput=socket
StandardError=journal
TimeoutStopSec=5

[Install]
WantedBy=multi-user.target
EOL

cat >> /etc/systemd/system/dymo-450-tape.socket <<EOL
[Unit]
Description=dymo-450-tape-socket

[Socket]
ListenStream=9102
Accept=yes
NoDelay=true

[Install]
WantedBy=sockets.target
EOL

systemctl daemon-reload
systemctl enable lprint
systemctl start lprint
systemctl enable dymo-450-label.socket
systemctl start dymo-450-label.socket
systemctl enable dymo-450-tape.socket
systemctl start dymo-450-tape.socket

lprint add -d dymo-450-label -v 'usb://DYMO/LabelWriter%20450%20DUO%20Label?serial=###' -m dymo_lw-450-duo-label -o orientation-requested=portrait -o print-color-mode=bi-level -o media-ready=oe_return-address-label_19x51mm

lprint add -d dymo-450-tape -v 'usb://DYMO/LabelWriter%20450%20DUO%20Tape?serial=###' -m dymo_lw-450-duo-tape -o media-ready=oe_continuous-label_12x7000mm -o media-ready-tracking=continuous -o media-ready-type=labels-continuous 
michaelrsweet commented 2 years ago

@CyrosX Thank you for this contribution, however there are a couple small things to note:

  1. PAPPL already supports a "native" option for managing port 910x printing, so the next version of LPrint (which is based on PAPPL) can just provide access to that option instead.
  2. Windows 10 and higher supports direct printing via IPP, so once the new version of LPrint is out you won't need to use the hack of port 9100 and the Dymo driver. Instead you can just discover the printer and print directly!

I'm moving this bug over to the PAPPL project so that I can add a standard option for controlling server options like this.

michaelrsweet commented 2 years ago

[master 4535610] Add 'server-options' option for mainloop applications (Issue #187)

The new option will be:

lprint server -o server-options=raw-port