description "Update notification regarding HP firmware installation"
author "Brian Murray <brian@ubuntu.com>"

# only idVendor=03f0, idProduct="??{17,2a}" requires firmware
start on (
    :sys:usb-device-added ID_VENDOR_ID=03f0 ID_MODEL_ID=??17 or
    :sys:usb-device-added ID_VENDOR_ID=03f0 ID_MODEL_ID=??2a or
    usb-device-added ID_VENDOR_ID=03f0 ID_MODEL_ID=??17 or
    usb-device-added ID_VENDOR_ID=03f0 ID_MODEL_ID=??2a
)

script
test -f /usr/bin/hp-mkuri || exit 0
DATE=$(date)
RESULT=0
hp_model="$ID_MODEL" /usr/bin/hp-mkuri -c || RESULT=$?
echo "$DATE hp-mkuri returned $RESULT"
# firmware is required if a 2 or a 5 is returned
if [ $RESULT -eq 2 ] || [ $RESULT -eq 5 ]; then
  /usr/bin/hp-plugin-ubuntu
fi
end script
