diff options
author | Moviuro <moviuro+git@gmail.com> | 2017-12-05 19:45:10 +0100 |
---|---|---|
committer | Moviuro <moviuro+git@gmail.com> | 2017-12-05 19:45:10 +0100 |
commit | 826683903393ea98209668ac920cb4365586ccb5 (patch) | |
tree | 5a80921407683225fcd83a206ba45987c175b6c1 | |
parent | 450f6efd081947120f6f2b603a786497f8edbd5b (diff) | |
download | rofi-pass-826683903393ea98209668ac920cb4365586ccb5.tar.gz |
rofi-pass: introduce the otp_method field
-rwxr-xr-x | rofi-pass | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -13,6 +13,7 @@ _rofi () { URL_field='url' USERNAME_field='user' AUTOTYPE_field='autotype' +OTPmethod_field='otp_method' default_autotype="user :tab pass" delay=2 @@ -82,7 +83,7 @@ autopass () { ":space") xdotool key space;; ":delay") sleep "${delay}";; ":enter") xdotool key Return;; - ":otp") printf '%s' "$(PASSWORD_STORE_DIR="${root}" pass otp ${selected_password})" | xdotool type --clearmodifiers --file -;; + ":otp") printf '%s' "$(generateOTP)" | xdotool type --clearmodifiers --file -;; "pass") printf '%s' "${password}" | xdotool type --clearmodifiers --file -;; *) printf '%s' "${stuff[${word}]}" | xdotool type --clearmodifiers --file -;; esac @@ -150,7 +151,7 @@ typeField () { xset r off case $typefield in - "OTP") to_type="$(PASSWORD_STORE_DIR="${root}" pass otp "$selected_password")" ;; + "OTP") to_type="$(generateOTP)" ;; *) to_type="${stuff[${typefield}]}" ;; esac @@ -163,6 +164,21 @@ typeField () { clearUp } +generateOTP () { + checkIfPass + + # First, we check if there is a non-conventional OTP command in the pass file + if PASSWORD_STORE_DIR="${root}" pass "$selected_password" | grep -q "${OTPmethod_field}: "; then + # We execute the commands after otp_method: AS-IS + bash -c "$(PASSWORD_STORE_DIR="${root}" pass "$selected_password" | grep "${OTPmethod_field}: " | cut -d' ' -f2-)" + else + # If there is no method defined, fallback to pass-otp + PASSWORD_STORE_DIR="${root}" pass otp "$selected_password" + fi + + clearUp +} + copyUser () { checkIfPass printf '%s' "${stuff[${USERNAME_field}]}" | doClip |