dotfiles/scripts/menu/menu-otp
2023-08-07 19:48:26 -06:00

18 lines
507 B
Bash
Executable file

#!/bin/sh
# OTP script for 'pass'
PASSWORD_STORE_DIR="$XDG_DATA_HOME/password-store"
# Ask for password name in vault
password=$(find "$PASWORD_STORE_DIR" -type f -name '*.gpg' |
sed 's/.*\/\(.*\)\.gpg$/\1/' | menu "OTP:")
# Exit if none chosen
[ -z "$password" ] && exit
# Otherwise, copy to clipboard and notify OTP
pass otp "$password" | while read -r OUTPUT; do
echo $OUTPUT | xsel -ib
xdotool type "$OUTPUT"
[ -e /usr/bin/notify-send ] && notify-send "$password" "$OUTPUT"
done