CAPS Universe documentation
1.0.4
All you need to know to be successful
|
Since all printer drivers needs to be triggered when the corresponding printing device gets attached to the host, some help from udev is required. The following udev rule file needs to be in place:
/ └── usr └── lib └── udev └── rules.d └── 99-caps.rules
This udev rule file matches if a USB based printer gets attached to the host and just starts a corresponding systemd service unit (e.g. caps-printer@
.service).
# starts the 'caps-printer@.service' unit whenever a USB printer device occurs # Everything between the @ and the .service will be used to form the %i or %I parameter # ACTION=="add", SUBSYSTEM=="usbmisc", ENV{DEVNAME}=="* /usb/lp*", TAG+="systemd", PROGRAM="/usr/bin/systemd-escape -p --template=caps-printer@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c"
How does it work:
ACTION=="add"
: run this line only, if the device is added to the systemSUBSYSTEM=="usbmisc"
: USB printers belongs to the usbmisc
subsystem, sorts out other USB devicesENV{DEVNAME}=="* /usb/lp*"
: the device node must match to this expression /dev/usb/lp0 would be the device node for the first printer in your systemIf one of these expression doesn't match, the device addition is ignored. If all of these expressions match, the remaining part of the line is processed:
TAG+="systemd"
: systemd should handle this eventPROGRAM="…"
: this starts a templated service unit and forwards the device node encoded to it. /dev/usb/lp0 needs to be encoded to dev-usb-lp0 to make it work.