rofi-yubikey/rofi-yubikey.sh

21 lines
521 B
Bash
Raw Permalink Normal View History

2025-01-01 16:33:34 +10:00
#!/usr/bin/env bash
# Get full list of account codes
output=$(/usr/bin/ykman oath accounts code)
# Get account names
accounts=$(echo "$output" | awk 'BEGIN{FS=OFS=" "}{$NF=""; NF--; print}')
# Get selected
selected=$(echo "$accounts"| \
rofi -no-show-icons -dmenu -i -p "YubiKey OATH Codes");
# If the user selects an entry
if [[ ! -z $selected ]]; then
# Copy code to the user's clipboard
echo "$output" | grep "$selected" | awk '{print $NF}' | xclip -selection clipboard;
fi
# Exit Rofi
exit 0