Add option to add OTP to passwords script

Using maim to get a screenshot of the QR code for OTP
This commit is contained in:
cronidea 2021-08-06 11:13:17 +01:00 committed by GitHub
parent 48a37badd5
commit 83558e2b1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,6 +28,19 @@ getTOTP() { \
fi
}
addTOTP() { \
name=$(printf "" | dmenu -i -p "What is the account name?")
if [ "$name" != "" ]
then
notify-send "📷 Please screenshot the QR code"
maim -m 10 -d 0.1 -s ~/.cache/totp-tmp.png
zbarimg -q --raw ~/.cache/totp-tmp.png | pass otp insert totp-$name
notify-send " OTP for totp-$name added!"
rm ~/.cache/totp-tmp.png
fi
unset name
}
addPassword() { \
name=$(printf "" | dmenu -i -p "What is the account name?")
if [ "$name" != "" ]
@ -45,7 +58,7 @@ addPassword() { \
removePassword() { \
name="$(pass | sed -r '1d;s/^├.{3}//;s/^└.{3}//' | dmenu -i -p "Passwords")"
sure="$(printf "No\\nYes" | dmenu -i -sb "#ac3333" -sf "#1d2021" -nf "#bbbbbb" -nb "#111111" -p "Are you sure?")"
sure="$(printf "No\\nYes" | dmenu -i -sb "#ac3333" -sf "#111111" -nf "#dddddd" -nb "#111111" -p "Are you sure?")"
if [ $sure = "Yes" ]
then
notify-send " Password for $name removed!"
@ -56,9 +69,10 @@ removePassword() { \
unset name
}
case "$(printf "Add password\\nRemove password\\nView password\\nView TOTP" | dmenu -i -p "Passwords")" in
case "$(printf "Add password\\nView password\\nView TOTP\\nAdd TOTP\\nRemove password" | dmenu -i -p "Passwords")" in
"Add password") addPassword ;;
"Remove password") removePassword ;;
"View password") getPasswords ;;
"Add TOTP") addTOTP ;;
"View TOTP") getTOTP ;;
"Remove password") removePassword ;;
esac