Linux Finerprint Reader and Lid State

I recently setup fprintd on my laptop so that I could use the fingerprint reader for login and unlocking 1Password. It worked well until I plugged my laptop into the dock and closed the lid. It was unfortunately still prompting me for a fingerprint, even when I did not have access to the reader.

After a search I found an article about how someone disabled the usb device on lid close so that it would stop this from happening. I only needed to find the correct device to disable. It was not listed in lsusb as a fingerprint reader, but the Archwiki had the information I needed. After that I just needed to find where it was in the device tree.

$ grep 06cb /sys/bus/usb/devices/*/idVendor
/sys/bus/usb/devices/3-3/idVendor:06cb

After adding the the following NixOS config everything worked just how it should.

services.acpid = {
    enable = true;
   lidEventCommands = ''
    grep -q close /proc/acpi/button/lid/LID/state
if [ $? = 0 ]; then
    echo 0 > /sys/bus/usb/devices/3-3/authorized
fi

grep -q open /proc/acpi/button/lid/LID/state
if [ $? = 0 ]; then
    echo 1 > /sys/bus/usb/devices/3-3/authorized
fi

exit 0
    '';
  };