diff --git a/.config/scripts/otp.sh b/.config/scripts/otp.sh new file mode 100755 index 0000000..d9f40f1 --- /dev/null +++ b/.config/scripts/otp.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +YUBIKEY_5C_IDENTIFIER="28854922" +YUBIKEY_NANO_IDENTIFIER="33923085" +YUBIKEY_SERIAL=$(ykman list | sed -n 's/.*Serial: //p') + +# Check for connected YubiKeys +if echo "$YUBIKEY_SERIAL" | grep -q "$YUBIKEY_5C_IDENTIFIER"; then + YUBIKEY_SERIAL=$YUBIKEY_5C_IDENTIFIER +elif echo "$YUBIKEY_SERIAL" | grep -q "$YUBIKEY_NANO_IDENTIFIER"; then + YUBIKEY_SERIAL=$YUBIKEY_NANO_IDENTIFIER +else + echo "No YubiKey detected!" + exit 1 +fi + +# Prompt for the password using zenity +password=$(zenity --password --title="Password Required" --text="Enter your password:") + +# Check if the user pressed Cancel +if [ $? -ne 0 ]; then + echo "Password dialog was cancelled." + exit 1 +fi + +accounts=$(ykman -d $YUBIKEY_SERIAL oath accounts list -p $password) + +# Create an array to hold the keys +declare -a keys + +# Read the input line by line +while IFS= read -r line; do + # Extract the part before the colon and store it in the array + key="${line%%:*}" + keys+=("$key") +done <<<"$accounts" + +selection=$(printf "%s\n" "${keys[@]}" | wofi -dmenu -i -p "New Session" --columns 1) + +ykman -d $YUBIKEY_SERIAL oath accounts code $selection -p $password | cut -d' ' -f3 | wl-copy diff --git a/ansible/roles/packages/vars/Archlinux.yml b/ansible/roles/packages/vars/Archlinux.yml index 8c37002..03fa72d 100644 --- a/ansible/roles/packages/vars/Archlinux.yml +++ b/ansible/roles/packages/vars/Archlinux.yml @@ -120,6 +120,7 @@ required_packages_pacman: - ccid - libfido2 - yubikey-manager + - zenity flatpak_remote: - { name: "flathub", url: "https://dl.flathub.org/repo/flathub.flatpakrepo" }