dotfiles/scripts/menu/menu-otp
2023-08-12 22:29:17 -06:00

18 lines
525 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 "$PASSWORD_STORE_DIR" -type f -name '*.gpg' |
sed "s@$PASSWORD_STORE_DIR/@@g ; s@.gpg@@g" | 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