From a25ec4ae258d229a4a2c34f015b754784b959c8d Mon Sep 17 00:00:00 2001 From: Joseph Hanson Date: Sun, 8 Sep 2024 18:02:17 -0500 Subject: [PATCH] added utility script to find correct usb device for the fingerprint reader. --- .../default.nix | 1 + .../findfp.sh | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 nixos/modules/nixos/system/fingerprint-reader-on-laptop-lid/findfp.sh diff --git a/nixos/modules/nixos/system/fingerprint-reader-on-laptop-lid/default.nix b/nixos/modules/nixos/system/fingerprint-reader-on-laptop-lid/default.nix index 2054628..6436d35 100644 --- a/nixos/modules/nixos/system/fingerprint-reader-on-laptop-lid/default.nix +++ b/nixos/modules/nixos/system/fingerprint-reader-on-laptop-lid/default.nix @@ -11,6 +11,7 @@ # ID 27c6:609c Shenzhen Goodix Technology Co.,Ltd # On Framework 16 the USB is: # Bus 005 Device 007: ID 27c6:609c Shenzhen Goodix Technology Co.,Ltd +# Use `findfp.sh` to find the correct USB device. { config, lib, pkgs, ... }: let cfg = config.mySystem.system.fingerprint-reader-on-laptop-lid; diff --git a/nixos/modules/nixos/system/fingerprint-reader-on-laptop-lid/findfp.sh b/nixos/modules/nixos/system/fingerprint-reader-on-laptop-lid/findfp.sh new file mode 100755 index 0000000..0205b2c --- /dev/null +++ b/nixos/modules/nixos/system/fingerprint-reader-on-laptop-lid/findfp.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +find_usb_device() { + local idVendor=$1 + local idProduct=$2 + local device_id="${idVendor}:${idProduct}" + + for device in /sys/bus/usb/devices/*; do + if [ -f "$device/idVendor" ] && [ -f "$device/idProduct" ]; then + vendor=$(cat "$device/idVendor") + product=$(cat "$device/idProduct") + if [ "${vendor}:${product}" = "$device_id" ]; then + echo "$device" + return 0 + fi + fi + done + + return 1 +} + +# Example usage +idVendor="27c6" +idProduct="609c" + +device_path=$(find_usb_device "$idVendor" "$idProduct") + +if [ -n "$device_path" ]; then + echo "Device found at: $device_path" + + # Print additional information + manufacturer=$(cat "$device_path/manufacturer" 2>/dev/null) + product=$(cat "$device_path/product" 2>/dev/null) + + echo "Manufacturer: ${manufacturer:-N/A}" + echo "Product: ${product:-N/A}" +else + echo "Device not found" +fi