summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyush Agarwal <ayush@fastmail.in>2022-02-16 22:19:12 +0530
committerAyush Agarwal <ayush@fastmail.in>2022-02-16 22:19:12 +0530
commitad8559beb88fd7a7d8df9e7ec6a00b3963cd9a2f (patch)
tree04fefcf6e1b6bd0f233a72730a91eccdf0a22e3c
parent9d0a8def782fca42031a9da9cb86d03614a306e7 (diff)
refactor: offload otp handling to key_otp
-rwxr-xr-xtessen15
1 files changed, 1 insertions, 14 deletions
diff --git a/tessen b/tessen
index b116dc0..1f7a1bf 100755
--- a/tessen
+++ b/tessen
@@ -416,8 +416,6 @@ key_open_url() {
# SECOND MENU: the default autotype function, either autotype the username and
# password or the custom autotype defined by the user
-# POTENTIAL IMPROVEMENT: Anything better than this ugly hack of
-# else..for..case..if..else..if?
auto_type_def() {
local word tmp_otp
@@ -432,18 +430,7 @@ auto_type_def() {
":tab") wtype -s "$tsn_delay" -k Tab -- ;;
":space") wtype -s "$tsn_delay" -k space -- ;;
":enter") wtype -s "$tsn_delay" -k Return -- ;;
- ":otp")
- if ! pass otp -h > /dev/null 2>&1; then
- _die "pass-otp is not installed"
- else
- tmp_otp="$(pass otp "$tsn_passfile")"
- if [[ "$tmp_otp" =~ ^[[:digit:]]+$ ]]; then
- printf "%s" "$tmp_otp" | wtype -s "$tsn_delay" -
- else
- _die "invalid OTP detected"
- fi
- fi
- ;;
+ ":otp") key_otp ;;
path | basename | filename) printf "%s" "${tsn_passfile##*/}" | wtype -s "$tsn_delay" - ;;
"$tsn_userkey") printf "%s" "$tsn_username" | wtype -s "$tsn_delay" - ;;
pass | password) printf "%s" "$tsn_password" | wtype -s "$tsn_delay" - ;;