change defaults. Enter shows menu with fields to type now. Hotkeys 1-3 remain (autotype, type user, type password)

This commit is contained in:
Rasmus Steinke 2016-07-26 01:01:33 +02:00
parent 27d4b80431
commit 38e02922e1

View File

@ -41,11 +41,6 @@ checkIfPass () {
autopass () { autopass () {
if [[ ${selected_password} == "[ Add Entry ]>" ]]; then
insertPass;
elif [[ ${selected_password} == "---" ]]; then
mainMenu;
else
rm -f "$HOME/.cache/rofi-pass/last_used" rm -f "$HOME/.cache/rofi-pass/last_used"
echo "${root}: $selected_password" > "$HOME/.cache/rofi-pass/last_used" echo "${root}: $selected_password" > "$HOME/.cache/rofi-pass/last_used"
chmod 600 "$HOME/.cache/rofi-pass/last_used" chmod 600 "$HOME/.cache/rofi-pass/last_used"
@ -80,7 +75,6 @@ autopass () {
xdotool key Return xdotool key Return
fi fi
fi fi
fi
} }
openURL () { openURL () {
@ -217,9 +211,6 @@ To perform default action use <span color='$help_color'>Enter</span>. For more h
rofi_exit=$? rofi_exit=$?
if [[ ${selected_password} == "[ Add Entry ]>" ]]; then
:
else
# generate Array of fields # generate Array of fields
password_temp=$(PASSWORD_STORE_DIR="${root}" pass "$selected_password") password_temp=$(PASSWORD_STORE_DIR="${root}" pass "$selected_password")
password=$(echo "${password_temp}" | head -1) password=$(echo "${password_temp}" | head -1)
@ -231,15 +222,21 @@ To perform default action use <span color='$help_color'>Enter</span>. For more h
done < <(PASSWORD_STORE_DIR="${root}" pass "${selected_password}" | tail -n+2 | grep -P '(: |:\t)' ) done < <(PASSWORD_STORE_DIR="${root}" pass "${selected_password}" | tail -n+2 | grep -P '(: |:\t)' )
stuff["pass"]=${password} stuff["pass"]=${password}
fi fi
if test "${stuff['autotype']+autotype}"
then
:
else
stuff["autotype"]="user :tab pass"
fi;
# actions based on keypresses # actions based on keypresses
if [[ "${rofi_exit}" -eq 0 ]]; then ${default_do}; if [[ "${rofi_exit}" -eq 0 ]]; then typeMenu;
elif [[ "${rofi_exit}" -eq 13 ]]; then openURL; elif [[ "${rofi_exit}" -eq 13 ]]; then openURL;
elif [[ "${rofi_exit}" -eq 1 ]]; then exit ${rofi_exit}; elif [[ "${rofi_exit}" -eq 1 ]]; then exit ${rofi_exit};
elif [[ "${rofi_exit}" -eq 10 ]]; then autopass; elif [[ "${rofi_exit}" -eq 10 ]]; then autopass;
elif [[ "${rofi_exit}" -eq 14 ]]; then copyMenu;
elif [[ "${rofi_exit}" -eq 11 ]]; then typeUser; elif [[ "${rofi_exit}" -eq 11 ]]; then typeUser;
elif [[ "${rofi_exit}" -eq 12 ]]; then typePass; elif [[ "${rofi_exit}" -eq 12 ]]; then typePass;
elif [[ "${rofi_exit}" -eq 14 ]]; then copyUser;
elif [[ "${rofi_exit}" -eq 17 ]]; then copyURL; elif [[ "${rofi_exit}" -eq 17 ]]; then copyURL;
elif [[ "${rofi_exit}" -eq 16 ]]; then viewEntry; elif [[ "${rofi_exit}" -eq 16 ]]; then viewEntry;
elif [[ "${rofi_exit}" -eq 15 ]]; then copyPass; elif [[ "${rofi_exit}" -eq 15 ]]; then copyPass;
@ -257,7 +254,6 @@ To perform default action use <span color='$help_color'>Enter</span>. For more h
unset selected_password unset selected_password
unset password_temp unset password_temp
unset stuff unset stuff
fi
} }
helpMenu () { helpMenu () {
@ -283,19 +279,17 @@ else unset helptext; mainMenu; fi
typeMenu () { typeMenu () {
checkIfPass checkIfPass
typefield=$({ echo -e "< Return\n---\npassword"; \ typefield=$(printf '%s\n' "${!stuff[@]}" | sort | _rofi -kb-accept-entry '!Return' -dmenu -p "Choose Field to type > ")
pass "${selected_password}" \ val=$?
| grep -P ':[\t ]' \ if [[ $val -eq 1 ]]; then
| gawk -F ':' '{ print $1 }';} \ exit
| _rofi -kb-accept-entry '!Return' \ fi
-dmenu \
-p "Choose Field to type > ")
if [[ $typefield == "" ]]; then if [[ $typefield == "" ]]; then
exit; exit;
elif [[ $typefield == "password" ]]; then elif [[ $typefield == "password" ]]; then
typePass; typePass;
elif [[ $typefield == "< Return" ]]; then elif [[ $typefield == "${AUTOTYPE_field}" ]]; then
mainMenu; autopass
else else
typeField typeField
fi fi
@ -303,19 +297,13 @@ typeMenu () {
copyMenu () { copyMenu () {
checkIfPass checkIfPass
copyfield=$({ echo -e "< Return\n---\npassword"; \ copyfield=$(printf '%s\n' "${!stuff[@]}" | sort | _rofi -kb-accept-entry '!Return' -dmenu -p "Choose Field to type > ")
pass "${selected_password}" \ val=$?
| grep -P ':[\t ]' \ if [[ $val -eq 1 ]]; then
| gawk -F ':' '{ print $1 }';} \
| _rofi -kb-accept-entry '!Return' \
-dmenu \
-p "Choose Field to copy > ")
if [[ $copyfield == "" ]]; then
exit; exit;
elif [[ $copyfield == "password" ]]; then fi
if [[ $copyfield == "password" ]]; then
copyPass; copyPass;
elif [[ $copyfield == "< Return" ]]; then
mainMenu;
else else
copyField copyField
fi fi