Pharos Printing from Linux
This document assumes you’re installing on a Debian 9.x computer, and that you’re printing to a Pharos release station, not to an actual Pharos printer queue. If you need the latter, you can probably add the functionality by recoding /usr/local/bin/pharospopup to ask for a password, and recoding /usr/lib/cups/backends/pharos to process that password, but I’ve not looked into that at all. Maybe next year, in the Year of the Linux Desktop ;-)
1 - Install CUPS
aptitude install cups
2 - Install Python
- Install Python
- aptitude install python
- Test for wx
- Start python (“python” at the command prompt)
- At the python prompt (>>>), type “import wx”. If you get no errors, great! If you get a message that no module named “wx” is found, you’ll have to install that piece (see below)
- Exit python with “quit()”.
- To install the wx modules,
- aptitude install python-wxgtk3.0
- Repeat the text for wx as above.
3 - Install pharos-linux
This is an open-source pharos client for Linux, written in python (which is why you installed python above).
- Web-browse to https://github.com/junaidali/pharos-linux
- On the green button to the right, that says “Clone or download”, choose “Download zip”.
- In a Terminal window, navigate to where you downloaded the zip file, and unzip it:
- cd ~/Downloads (for example)
- unzip pharos-linux-master.zip
- Navigate into the directory created by the unzipping above:
- cd pharos-linux-master
- Here you have to create a “printers.conf” file. This will be different than the CUPS “printers.conf”, so don’t get them confused. But you may need some info (like the printer driver name, etc) from the CUPS version of the file, so you may want to create a dummy printer temporarily in order to collect that info:
- Web-browse to “localhost:631”
- Use this normal CUPS interface to create a temporary lpd:// version of the printer you’re wanting to install. Make sure to make it as accurate as you can, including the IP address and model and driver.
- Now that you’ve created a temporary dummy printer in CUPS, you can look in the “/etc/cups/printers.conf” file for some of the info you’ll need in the pharos “printers.conf” file. Create/edit “printers.conf”. Mine, for an HP Laserjet p4015dn printer, looks like this:
# ACU Brown Library Kiosk Printer Configuration File
[Printers]
printers=BLKiosk_1
[BLKiosk_1]
Make=HP
Model=LaserJet p4015dn
Driver=hpcups
LPDServer=tychicus.acu.edu
LPDQueue=BLKiosk_1
Location=Brown Library Circ Desk
Description=Circulation Desk Printer
[Printers]
printers=BLKiosk_1
[BLKiosk_1]
Make=HP
Model=LaserJet p4015dn
Driver=hpcups
LPDServer=tychicus.acu.edu
LPDQueue=BLKiosk_1
Location=Brown Library Circ Desk
Description=Circulation Desk Printer
The “README” and “CONFIGURATION” files may provide you some help.
On one of my machines, I had to aptitude install printer-driver-hpcups to get the correct driver installed for this printer.
- Now that you’ve created the pharos version of the “printers.conf”, you can run the pharos setup program:
- ./setup.py
- If all goes well, you should see a message that remote printing has been successfully installed.
- This created a new “backend” processor for CUPS, named “pharos”. This is what allows you to select “pharos” as the protocol when you add (or modify, as in the next step) a new printer. If you're curious to see the file, you can find this new backend in the “/usr/lib/cups/backend” (“/usr/libexec/cups/backend” on Macintosh, just FYI) directory.
- It installed some executables and config files in “/usr/local”, such as “/usr/local/bin/pharospopup” (which is the python script that creates the popup window when you print).
- It created a symlink to “/usr/local/bin/pharospopup” in the KDE or Gnome startup locations of any users it found on the system, so that the popup client "daemon" will be running in the background when you start KDE/Gnome, which watches for print jobs sent to the Pharos printer and then pops up the credentials window. In my case, running XFCE4 instead of KDE or Gnome, I had to manually create an autostart item (using the XFCE4 System Settings GUI, but I could have done it by hand in the “~/.config/xfce4/autostart” directory) that runs the “/usr/local/bin/pharospopup” executable” when XFCE4 starts up. When this executable is running, you should be able to see it with a “ps ax | grep pharos”. If it’s not running, something’s wrong (did you log out / back in?).
- Now you need to go back to your CUPS configuration page (web-browse to localhost:631), and “Modify” your temporary printer, changing only the protocol from the lpd:// you used earlier to the newly-available “Pharos” protocol (not named that; can’t recall or access at the moment).
- If all has gone well, when you try to print, you’ll get a popup asking for printing credentials, and all should be working.
- If your printer dialog has more printers than just the ones you want, you can turn that off. Apparently in earlier versions, the “browse” options in “/etc/cups/cups.conf”, or the “/etc/cups/cupsd-browsed” were controlling factors, but now Avahi seems to override those settings. (You can even turn off CUPS altogether, and your wanted printer goes away, but the autodiscovered ones remain. Arg.) I’m currently testing how best to do this. Here are three possible options:
- Turn off avahi-daemon altogether. Avahi is related to (the same as?) ZeroConf / Bonjour / Rendevouz / Auto-discovery. You’d think that you could turn it off with a simple:
systemctl disable avahi-daemon
but on reboot, it seems to be back in service. Flipping the bit in “/etc/default/avahi-daemon” doesn’t help either. You might have to tweak the avahi files in “/etc/init.d” to disable it.
- Tell Avahi to not publish on dbus the devices it finds. Edit “/etc/avahi/avahi-daemon.conf”, uncommenting the line under “[server]” that says “enable-dbus=yes”, and changing the “yes” to “no”.
- Tell the GTK-3 applications (like Firefox) to not use the devices published by Avahi. Create “/etc/gtk-3.0/settings.ini”, and add the following content to it:
[Settings]
gtk-print-backends=file
(the default, without this setting, is "gtk-print-backends=file,cups)
Of these three methods, I’ve had the best results with “b”.
You should now be able to print to a Pharos printer from Linux. I edited the “/usr/local/bin/pharospopup” python script to swap out “myACU” for “myITT”, and to tweak the “release station” to “the Circulation Desk”. Now the popup is customized more specifically for my environment.