#!/bin/bash # omarchy:summary=Set up fingerprint authentication for sudo, polkit, and lock screen # omarchy:requires-sudo=true set -e check_fingerprint_hardware() { # Get fingerprint devices for the user devices=$(fprintd-list "$USER" 2>/dev/null) # Exit if no devices found if [[ -z $devices ]]; then echo -e "\e[31m\nNo fingerprint sensor detected.\e[0m" return 1 fi return 0 } setup_pam_config() { # Configure sudo if ! grep -q pam_fprintd.so /etc/pam.d/sudo; then echo "Configuring sudo for fingerprint authentication..." sudo sed -i '1i auth sufficient pam_fprintd.so' /etc/pam.d/sudo fi # Configure polkit if [[ -f /etc/pam.d/polkit-1 ]] && ! grep -q 'pam_fprintd.so' /etc/pam.d/polkit-1; then echo "Configuring polkit for fingerprint authentication..." sudo sed -i '1i auth sufficient pam_fprintd.so' /etc/pam.d/polkit-1 elif [[ ! -f /etc/pam.d/polkit-1 ]]; then echo "Creating polkit configuration with fingerprint authentication..." sudo tee /etc/pam.d/polkit-1 >/dev/null <<'EOF' auth sufficient pam_fprintd.so auth required pam_unix.so account required pam_unix.so password required pam_unix.so session required pam_unix.so EOF fi } setup_lock_fingerprint_pam() { echo "Configuring lock screen for fingerprint authentication..." sudo tee /etc/pam.d/omarchy-lock-fingerprint >/dev/null <<'EOF' #%PAM-1.0 auth required pam_fprintd.so account include system-local-login EOF } echo -e "\e[32mSetting up fingerprint scanner for authentication.\n\e[0m" # Install required packages echo "Installing required packages..." # libfprint-git provides+conflicts libfprint; pacman -S --noconfirm # defaults the conflict prompt to N and aborts. Pre-remove libfprint # with -Rdd so the install goes silent. -Rdd (not omarchy-pkg-drop's # -Rns) is required because fprintd requires libfprint; the dep is # re-satisfied immediately by libfprint-git's provides=libfprint. if omarchy-pkg-present libfprint; then sudo pacman -Rdd --noconfirm libfprint fi omarchy-pkg-add libfprint-git fprintd usbutils if ! check_fingerprint_hardware; then exit 1 fi # Configure PAM setup_pam_config # Enroll first fingerprint echo -e "\e[32m\nLet's setup your right index finger as the first fingerprint.\e[0m" echo -e "Keep moving the finger around on sensor until the process completes.\n" if sudo fprintd-enroll "$USER"; then echo -e "\e[32m\nFingerprint enrolled successfully!\e[0m" # Verify echo -e "\nNow let's verify that it's working correctly.\n" if fprintd-verify; then setup_lock_fingerprint_pam echo -e "\e[32m\nPerfect! Fingerprint authentication is now configured.\e[0m" echo "You can use your fingerprint for sudo, polkit, and lock screen (Super + Ctrl + L)." else echo -e "\e[31m\nVerification failed. You may want to try enrolling again.\e[0m" fi else echo -e "\e[31m\nEnrollment failed. Please try again.\e[0m" exit 1 fi