aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xrofi-pass20
1 files changed, 18 insertions, 2 deletions
diff --git a/rofi-pass b/rofi-pass
index 56d59c7..36e8ba3 100755
--- a/rofi-pass
+++ b/rofi-pass
@@ -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