Cat Printer with CUPS, Netatalk/Appletalk - Tue, Mar 19, 2024
Get your cheap thermal bluetooth printer up and running with your old Macintosh computers
What is a Cat Printer
Cat Printer is a thermal printer that can be gotten for real cheap at places such as aliexpress or amazon. There are many different models and some of their protocols been reverse-engineered so that you can use a open source application on your phone or computer to print to it.
- Example printer: https://www.aliexpress.com/item/1005004306434906.html
- Open source tooling: https://github.com/NaitLee/Cat-Printer
Using CUPS with Cat Printer
RaspberryPi with Bluetooth
Find yourself a computer of some sorts with bluetooth support, either through a USB bluetooth device or native on the board. I originally wanted to use my RaspberryPi 2 Model B v1.1 with a USB bluetooth receiver, but I couldn’t get it to work so I had to spring for the 4 Model B that I also had at hand. My recommendation is to go for the cheapest or most available device that you have on hand, it doesn’t even have to be a single board computer.
Install Bluetooth tooling
apt install bluetooth pi-bluetooth bluez bluez-utils
Once these packages have installed, reboot your Raspberry Pi by typing sudo reboot. You’ll need to re-establish your SSH connection if you’re connecting remotely.
Test that bluetooth works as intended
bluetoothctl
scan on
If you see some devices then your bluetooth should be working.
CUPS with Netatalk support
Install CUPS (From: https://netatalk.io/docs/Installing-Netatalk-2-on-Debian)
apt install \
autoconf \
automake \
docbook-xsl \
libacl1-dev \
libavahi-client-dev \
libcrack2-dev \
libcups2-dev \
libdb-dev \
libgcrypt-dev \
libkrb5-dev \
libldap2-dev \
libltdl-dev \
libpam0g-dev \
libssl-dev \
libtirpc-dev \
libtool \
libtool-bin \
libwrap0-dev \
quota \
tcpd
apt install libcups2-dev cups
Make sure that anyone on your network can access CUPS and that your user has admin access:
usermod -a -G lpadmin $USER
cupsctl --remote-admin WebInterface=yes
A good tip is to modify /etc/cups/cupsd.conf with “MaxLogSize 1000” and “PreserveJobHistory No” to make sure that you don’t run out of space on your device. I also added to allow any IP/DNS to access the administrative interface so the top of my cupsd.conf looks like:
LogLevel warn
PageLogFormat
MaxLogSize 1000
ErrorPolicy retry-job
# Allow remote access
ServerAlias *
Install Netatalk (From: https://netatalk.io/docs/Print-Server)
Now get the latest release tarball of Netatalk 2 from https://netatalk.io/download.html I just used wget with the sourceforge download link as such:
wget "https://downloads.sourceforge.net/project/netatalk/netatalk-2-3-1/netatalk-2.3.1.tar.xz?ts=asldfholsdhflsdhkfalsfd" -O netatalk.tar.gz
tar -xvf netatalk.tar.gz
cd netatalk-2.3.1/
./configure
After ./configure make sure that it says that it has configured netatalk with CUPS support. Then compile netatalk:
make
make install
Setup Cat Printer
Install dependencies
apt install imagemagick ghostscript
Get the source code and set the environment up
git clone https://github.com/NaitLee/Cat-Printer
./install.sh
Start the Cat Printer server in tmux
tmux
python server.py -a -s
Make sure that you can access Cat Printer through the WebUI and do a test print by going to http://127.0.0.1:8095/ and linking up to your bluetooth Cat Printer by clicking Scan and chosing your device.
Add Cat Printer to CUPS
From: https://github.com/NaitLee/Cat-Printer/discussions/8#discussioncomment-2557843
First go to your CUPS administrator page: https://127.0.0.1:631/ and go to Administration
- In CUPS, add URL ipp://127.0.0.1:8095/ as a Generic PostScript Printer.
- You can (not required) append string after the url, like GB02 or GB02,61:06:ff:7d:8d:fd, for picking the correct printer.
- While printing, it will directly invoke Ghostscript (gs in Linux) for converting to PBM image format.
- Optionally, config printer settings though Web interface.
- Try it with something like LibreOffice! Use an A4 portrait paper, and a bigger font (probably more than 32pt)
Setup papd
The next step is to configure papd. Edit /usr/local/etc/netatalk/papd.conf and add the following line to the bottom of the file:
cupsautoadd:op=root:
Save, exit, and restart papd
service papd restart
At this stage, you want to test that the CUPS printer is shared over AppleTalk. This can be done using this command:
$ nbplkup
The output should look something like this:
print01:/# nbplkup
Brother HL L2350DW series:LaserWriter 65280.97:130
cat:LaserWriter 65280.97:129
cat print01:LaserWriter 65280.97:128
LittleRed PowerPC G3 192.0MB:AFPServer 65280.128:248
LittleRed PowerPC G3 192.0MB:ARA - Personal Server 65280.128:2
LittleRed PowerPC G3 192.0MB:Multi-User Client 65280.128:48
LittleRed PowerPC G3 192.0MB:MLS 2.0 65280.128:39
LittleRed PowerPC G3 192.0MB: Power Macintosh 65280.128:252
LittleRed PowerPC G3 192.0MB:Workstation 65280.128:4
Install the printer on your Macintosh
The next steps should be as with any other printer in Macintosh OS7-9, as long as your computer is up and running on the same network you should be seeing the printer in the “Chooser” application. Add it as a “Generic” printer and print away!
Setup a Fileshare
Create and set permissions on a directory you want to share
The default guest user is called “nobody” and part of the guest group “nogroup”. Create a directory and give the default guest user and group access. Set permissions to something useful for a guest share.
mkdir /media/hamiNet
chown nobody:nogroup /media/hamiNet
chmod a+x /media/hamiNet
/usr/local/etc/netatalk/AppleVolumes.default
This file specifies which paths you want to share and the settings for directory. Change the bottom of the file to:
#~
/media/hamiNet "hamiNet share" volsizelimit:2000
/usr/local/etc/netatalk/afpd.conf
This file specifies how authentication to the file share will be done. Change the bottom of the file to:
# Default server -
# With guest login -uamlist uams_guest.so
# Do not save password -nosavepassword
# Make "AFP over AppleTalk" available -ddp
# Do not use tcp -notcp
# Write the following login message -loginmesg
- -uamlist uams_guest.so -nosavepassword -ddp -notcp -nouservol -loginmesg "This is hamiNet, ping me on @hamin@mastodon.acc.sunet.se :)"
/usr/local/etc/netatalk/netatalk.conf
General netatalk settings. Change the bottom of the file to:
#########################################################################
# AppleTalk specific configuration (legacy)
#########################################################################
#### Set which legacy daemons to run.
#### If you need AppleTalk, run atalkd.
#### papd, timelord and a2boot are dependent upon atalkd.
ATALKD_RUN=yes
PAPD_RUN=yes
#TIMELORD_RUN=no
#A2BOOT_RUN=no
#### Control whether the daemons are started in the background.
#### If it is dissatisfied that legacy atalkd starts slowly, set "yes".
#### In case using systemd/systemctl, this is not so significant.
#ATALK_BGROUND=no
#### Set the AppleTalk Zone name.
#### NOTE: if your zone has spaces in it, you're better off specifying
#### it in atalkd.conf
ATALK_ZONE=@hamiNet
Restart afpd and now your share should be available on Appletalk for your retro Macintosh computers
service afpd restart