21 lines
521 B
Bash
Executable File
21 lines
521 B
Bash
Executable File
#!/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
|