Category Archives: Raspberry Pi

Getting HP p1005 and associated LaserJet printers working with Raspberry Pi

The standard hplip doesn’t seem to work very well on the Raspberry Pi with printers like the HP LaserJet 1000/1005/1018/1020/P1005/P1006/P1007/P1008/P1505 as they need a custom firmware downloading to them before being able to print anything. This seems like an issue with the firmware download or page formatting tool which just make the printer give a click sound and do no more. This is annoying because I was wanting to use my Raspberry Pi as a file and print server – my all-in-one HP DeskJet F2420 set up really easily but I was struggling for a long time to make the LaserJet work correctly.

The basic way to make this work is to download and compile the foo2zjs open source printer driver (as the apt sources don’t seem to be working properly at least on my slightly older version of Raspian). After having downloaded and compiled you install using the following commands:

rm /etc/udev/rules.d/*hpmud* # remove any existing hotplug from HP
./getweb P1005 # change depending on your printer
make install
make install-hotplug
make cups

For some reason the install script didn’t seem to correctly install the firmware on my system so I had to work around it:

mkdir -p /usr/share/foo2xqx/firmware/
mv sihp* /usr/share/foo2xqx/firmware/

If you want to test without having to use cups, try the following (after turning your printer off and on again):

foo2xqx-wrapper testpage.ps > testpage.xq # convert to wire-format
cat /usr/share/foo2xqx/firmware/sihpP1005.dl > /dev/usb/lp0 # bang firmware over to printer (wait 5 sec for it to install)
cp testpage.xq /dev/usb/lp0 # print the page (hopefully)

Depending on printer you may need to use foo2zjs-wrapper instead of foo2xqx-wrapper.

Then you have proved it works so you can set it up in cups nice and easily and use it as a remote printer!

Automatically removing a torrent when it has finished downloading

So as not to saturate my (very limited) uplink when a torrent as finished downloading (using transmission-daemon on my Raspberry Pi) I wanted it to be removed automatically. There were a number of docs on the web about how to do this but here is a simple 2-line file that will do it:

#!/bin/bash
transmission-remote -t $TR_TORRENT_ID -r

Save this as /usr/bin/torrent-complete.sh, chmod +x the script. Stop transmission-deamon (you need to do this rather than a restart as it always dumps the current live config on stop/restart so any changes you make while it is running will be nuked) Then open up /etc/transmission-daemon/settings.json and add (or modify) the following lines:

    "script-torrent-done-enabled": true,
    "script-torrent-done-filename": "/usr/bin/torrent-complete.sh",

Start up transmission-deamon and there you go.