diff options
author | Rasmus Steinke <rasi@xssn.at> | 2015-12-27 08:13:52 +0100 |
---|---|---|
committer | Rasmus Steinke <rasi@xssn.at> | 2015-12-27 08:13:52 +0100 |
commit | a97cf6e86afc8a6420d72772791664ddae3efcbd (patch) | |
tree | d5972e22a9f6f519c342f648c2f05d4e224239a8 | |
parent | a5641729476f7e72bcf1660342cf03dc7ef024fe (diff) | |
download | rofi-pass-a97cf6e86afc8a6420d72772791664ddae3efcbd.tar.gz |
add --bmarks switch and $switch keybind to change mode on the fly
-rwxr-xr-x | rofi-pass | 149 |
1 files changed, 87 insertions, 62 deletions
@@ -2,7 +2,7 @@ # rofi-pass # (c) 2015 Rasmus Steinke <rasi@xssn.at> - +basecommand=$(echo "$0" | awk '{ print $1 }') # get all password files and create an array list_passwords() { @@ -145,70 +145,91 @@ generatePass () { # main Menu mainMenu () { - unset selected_password - help_text=$(echo -e "Enter: Autotype - ${action_menu}: Actions - ${show}: View\n${type_menu}: Type Field - ${copy_menu}: Copy Field - ${help}: Help" | column -s '-' -t) - line1=$(echo "${help_text}" | head -1) - line3=$(echo "${help_text}" | tail -1) + if [[ $1 == "--bmarks" ]]; then + selected_password="$(echo -e "$(list_passwords 2>/dev/null)" \ + | _rofi -mesg "Bookmarks Mode. ${switch} to switch" \ + -dmenu \ + -kb-custom-1 "Alt+x" \ + -select "$entry" \ + -p "rofi-pass > ")" + + rofi_exit=$? + + if [[ $rofi_exit -eq 1 ]]; then + exit + elif [[ $rofi_exit -eq 10 ]]; then + $(${basecommand}) + elif [[ $rofi_exit -eq 0 ]]; then + openURL + fi + else + unset selected_password + help_text=$(echo -e "Enter: Autotype - ${action_menu}: Actions - ${show}: View\n${type_menu}: Type Field - ${copy_menu}: Copy Field - ${help}: Help" | column -s '-' -t) + line1=$(echo "${help_text}" | head -1) + line3=$(echo "${help_text}" | tail -1) HELP="<span color='$help_color'>${line1} ${line3}</span>" - selected_password="$(echo -e "[ Add Entry ]>\n---\n$(list_passwords 2>/dev/null)" \ - | _rofi -mesg "${HELP}" \ - -dmenu -kb-custom-1 "${autotype}" \ - -kb-custom-2 "${type_user}" \ - -kb-custom-3 "${type_pass}" \ - -kb-custom-4 "${open_url}" \ - -kb-custom-5 "${copy_name}" \ - -kb-custom-6 "${copy_pass}" \ - -kb-custom-7 "${show}" \ - -kb-custom-8 "${copy_url}" \ - -kb-custom-13 "${type_menu}" \ - -kb-custom-14 "${action_menu}" \ - -kb-custom-15 "${copy_menu}" \ - -kb-custom-16 "${help}" \ - -dmenu \ - -select "$entry" \ - -p "rofi-pass > ")" - - rofi_exit=$? - - if [[ ${selected_password} == "[ Add Entry ]>" ]]; then - : - else - # generate Array of fields - password_temp=$(PASSWORD_STORE_DIR="${root}" pass "$selected_password") - password=$(echo "${password_temp}" | head -1) - declare -A stuff - while read LINE; do - _id=$(echo -e "${LINE}" | awk -F ':[[:space:]]*' '{print $1}') - _val=$(echo -e "${LINE}" | awk '{sub(/:/,"")}{for (i=2; i<NF; i++) printf $i " "; print $NF}') - stuff["${_id}"]=${_val} - done < <(PASSWORD_STORE_DIR="${root}" pass "${selected_password}" | tail -n+2 | grep -P '(: |:\t)' ) - stuff["pass"]=${password} - fi + selected_password="$(echo -e "[ Add Entry ]>\n---\n$(list_passwords 2>/dev/null)" \ + | _rofi -mesg "${HELP}" \ + -dmenu -kb-custom-1 "${autotype}" \ + -kb-custom-2 "${type_user}" \ + -kb-custom-3 "${type_pass}" \ + -kb-custom-4 "${open_url}" \ + -kb-custom-5 "${copy_name}" \ + -kb-custom-6 "${copy_pass}" \ + -kb-custom-7 "${show}" \ + -kb-custom-8 "${copy_url}" \ + -kb-custom-13 "${type_menu}" \ + -kb-custom-14 "${action_menu}" \ + -kb-custom-15 "${copy_menu}" \ + -kb-custom-16 "${help}" \ + -kb-custom-17 "${switch}" \ + -dmenu \ + -select "$entry" \ + -p "rofi-pass > ")" + + rofi_exit=$? + + if [[ ${selected_password} == "[ Add Entry ]>" ]]; then + : + else + # generate Array of fields + password_temp=$(PASSWORD_STORE_DIR="${root}" pass "$selected_password") + password=$(echo "${password_temp}" | head -1) + declare -A stuff + while read LINE; do + _id=$(echo -e "${LINE}" | awk -F ':[[:space:]]*' '{print $1}') + _val=$(echo -e "${LINE}" | awk '{sub(/:/,"")}{for (i=2; i<NF; i++) printf $i " "; print $NF}') + stuff["${_id}"]=${_val} + done < <(PASSWORD_STORE_DIR="${root}" pass "${selected_password}" | tail -n+2 | grep -P '(: |:\t)' ) + stuff["pass"]=${password} + fi - # actions based on keypresses - if [[ "${rofi_exit}" -eq 0 ]]; then autopass; - elif [[ "${rofi_exit}" -eq 13 ]]; then openURL; - elif [[ "${rofi_exit}" -eq 1 ]]; then exit ${rofi_exit}; - elif [[ "${rofi_exit}" -eq 10 ]]; then autopass; - elif [[ "${rofi_exit}" -eq 11 ]]; then typeUser; - 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 16 ]]; then viewEntry; - elif [[ "${rofi_exit}" -eq 15 ]]; then copyPass; - elif [[ "${rofi_exit}" -eq 22 ]]; then typeMenu; - elif [[ "${rofi_exit}" -eq 23 ]]; then actionMenu; - elif [[ "${rofi_exit}" -eq 25 ]]; then unset selected_password; helpMenu; - elif [[ "${rofi_exit}" -eq 24 ]]; then copyMenu; + # actions based on keypresses + if [[ "${rofi_exit}" -eq 0 ]]; then autopass; + elif [[ "${rofi_exit}" -eq 13 ]]; then openURL; + elif [[ "${rofi_exit}" -eq 1 ]]; then exit ${rofi_exit}; + elif [[ "${rofi_exit}" -eq 10 ]]; then autopass; + elif [[ "${rofi_exit}" -eq 11 ]]; then typeUser; + 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 16 ]]; then viewEntry; + elif [[ "${rofi_exit}" -eq 15 ]]; then copyPass; + elif [[ "${rofi_exit}" -eq 22 ]]; then typeMenu; + elif [[ "${rofi_exit}" -eq 23 ]]; then actionMenu; + elif [[ "${rofi_exit}" -eq 25 ]]; then unset selected_password; helpMenu; + elif [[ "${rofi_exit}" -eq 24 ]]; then copyMenu; + elif [[ "${rofi_exit}" -eq 26 ]]; then $(${basecommand} --bmarks); + fi + password='' + selected_password='' + unset stuff + unset password + unset selected_password + unset password_temp + unset stuff fi - password='' - selected_password='' - unset stuff - unset password - unset selected_password - unset password_temp - unset stuff } helpMenu () { @@ -223,7 +244,8 @@ ${copy_url}: Copy URL ${copy_menu}: Copy Custom Field --- ${action_menu}: Edit, Move, Delete, Re-generate Submenu -${show}: Show Password File" | _rofi -dmenu -p "Help > ") +${show}: Show Password File +Alt+x: Switch Pass/Bookmark Mode" | _rofi -dmenu -p "Help > ") if [[ $help == "" ]]; then exit; else unset helptext; mainMenu; fi } @@ -510,6 +532,9 @@ export PASSWORD_STORE_DIR="${root}" --show-last) selected_password="$(awk -F ': ' '{ print $2 }' $HOME/.config/rofi-pass/last_used)" showEntry ;; + --bmarks) + mainMenu --bmarks; + ;; *) mainMenu ;; |