diff options
author | Rasmus Steinke <rasi@xssn.at> | 2016-05-25 00:49:54 +0200 |
---|---|---|
committer | Rasmus Steinke <rasi@xssn.at> | 2016-05-25 00:49:54 +0200 |
commit | 64c9a26a21e8d7c1ef62edd5b4be0d4549b32f5e (patch) | |
tree | 924e8715cf527c1a71a2d5296e383ad16fb86da0 | |
parent | ee6279a8b968af307a63ca474f225dc9b45126b0 (diff) | |
parent | fa36f54db3c7bda6d0b32702776ae26dd3efb463 (diff) | |
download | rofi-pass-64c9a26a21e8d7c1ef62edd5b4be0d4549b32f5e.tar.gz |
Merge pull request #42 from carnager/template
merge Template branch
-rw-r--r-- | config.example | 5 | ||||
-rwxr-xr-x | rofi-pass | 116 |
2 files changed, 25 insertions, 96 deletions
diff --git a/config.example b/config.example index 80a067a..fb03d83 100644 --- a/config.example +++ b/config.example @@ -41,6 +41,11 @@ help_color="" # Possible options: primary, clipboard, both clip=primary +# Options for generating new password entries +default_user=john_doe +default_user2=mary_ann +password_length=12 + # Custom Keybindings autotype="Alt+1" type_user="Alt+2" @@ -384,108 +384,32 @@ manageEntry () { fi } -insertPass () { - if [[ -z "$pass" ]]; then - if [[ -n "$1" ]]; then - pass="$1" - pass2="***" - else - pass2="Empty" - fi - fi - if [[ -z "$user" ]]; then user="Empty"; fi - if [[ -z "$domain" ]]; then domain="Empty"; fi - if [[ -z "$name" ]]; then name="Empty"; fi - - insertmenu=$({ echo -e "0 Return to Main Menu\n* Accept Values and Add Password Entry\n---"; echo "1 Name ($name)"; echo "2 URL ($domain)"; echo "3 User ($user)"; echo "4 Password ($pass2)"; } | _rofi -dmenu -mesg "<span color='$help_color'>For faster adding use the addpass command</span>" -p "Add Entry > ") - insert_val=$? - if [[ $insert_val -eq 1 ]]; then exit - else - if [[ $insertmenu == "0 Return to Main Menu" ]]; then mainMenu - elif [[ $insertmenu == "" ]]; then exit - elif [[ $insertmenu == "* Accept Values and Add Password Entry" ]]; then - cd "${root}" || exit - group=$({ echo -e "No Group\n---"; find -type d -not -iwholename '*.git*' -printf '%d\t%P\n' | sort -r -nk1 | cut -f2-;} | _rofi -dmenu -p "Choose Group > ") - if [[ "$group" == "No Group" ]]; then - { - echo "${pass}" - echo "${USERNAME_field}: ${user}" - echo "---" - echo "${URL_field}: ${domain}" - } | PASSWORD_STORE_DIR="${root}" pass insert -m -f "${name}" - elif [[ "$group" == "" ]]; then - exit - else - { - echo "${pass}" - echo "${USERNAME_field}: ${user}" - echo "---" - echo "${URL_field}: ${domain}" - } | PASSWORD_STORE_DIR="${root}" pass insert -m -f "${group}/${name}" - fi - exit - elif [[ $insertmenu == "1 Name"* ]]; then - name=$(echo "" | _rofi -dmenu -p "Enter Name > ") - insertPass - - elif [[ $insertmenu == "2 URL"* ]]; then - HELP="<span color='$help_color'>Enter Domain Name</span>" - domain=$(echo -e "< Return" | _rofi -dmenu -mesg "${HELP}" -p "URL > ") - if [[ $domain == "< Return" ]]; then - insertPass - elif [[ $domain == "" ]]; then - exit - else - insertPass - fi - elif [[ $insertmenu == "3 User"* ]]; then - HELP="<span color='$help_color'>Enter Username</span>" - user=$(echo -e "" | _rofi -dmenu -mesg "${HELP}" -p "Username > ") - insertPass - elif [[ $insertmenu == "4 Password"* ]]; then - password_length=12 - symbols="False" - numerals="True" - capitals="True" - password_gen - else - insertPass - fi - fi +listgpg () { + find . -name \*.gpg -print | xargs -d '\n' -n 1 | cut -c 3- | while read line; do echo -e "$(basename "${line%*.gpg}")\t(In: "$(dirname "${line}")")"; done | column -s $'\t' -t } -password_gen () { - if [[ $capitals == "True" ]]; then cap="-c"; else cap="-A"; fi - if [[ $symbols == "True" ]]; then sym="-y"; else sym=""; fi - if [[ $numerals == "True" ]]; then num="-n"; else num="-0"; fi - HELP="<span color='$help_color'>Choose one password or type your own</span>" - menu=$(echo -e "0 Return to Insert Menu\n* Generate new Password\n---\n1 Password Length\n2 Include Capitals ($capitals)\n3 Include Numerals ($numerals)\n4 Include Symbols ($symbols)\n---\n$(pwgen $num $cap $sym -B -1 $password_length 5)" | _rofi -dmenu -mesg "${HELP}" -p "Password > ") - - if [[ $menu == "1 Password Length" ]]; then - password_length=$(echo -e "5\n7\n10\n12\n15\n20" | _rofi -dmenu -p "Choose Length > ") - password_gen - elif [[ $menu == "0 Return to Insert Menu" ]]; then - insertPass - elif [[ $menu == "* Generate new Password" ]]; then - password_gen - elif [[ $menu == "2 Include Capitals"* ]]; then - capitals=$(echo -e "True\nFalse" | _rofi -dmenu -p "Capitals? > ") - password_gen - elif [[ $menu == "3 Include Numerals"* ]]; then - numerals=$(echo -e "True\nFalse" | _rofi -dmenu -p "Numerals? > ") - password_gen - elif [[ $menu == "4 Include Symbols"* ]]; then - symbols=$(echo -e "True\nFalse" | _rofi -dmenu -p "Symbols? > ") - password_gen +insertPass () { + cd "${root}" + name="$(listgpg | rofi -dmenu -format 'f' -mesg "Type name, make sure it is unique" -p "> ")" +# name="$(echo -e "$(list_passwords 2>/dev/null)" | rofi -dmenu -mesg "Type name, make sure it is unique" -p "> ")" + val=$? + if [[ $val -eq 1 ]]; then exit; fi + user=$(echo -e "${default_user2}\n$USER\n${default_user}" | rofi -dmenu -mesg "Chose Username or type" -p "> ") + val=$? + if [[ $val -eq 1 ]]; then exit; fi + group=$(echo -e "No Group\n---\n$(find -type d -not -iwholename '*.git*' -printf '%d\t%P\n' | sort -r -nk1 | cut -f2-)" | rofi -dmenu -p "Choose Group > ") + val=$? + if [[ $val -eq 1 ]]; then exit; fi + + if [[ "$group" == "No Group" ]]; then + echo $EDITOR + echo -e "PASS\n---\nuser: $user" | PASSWORD_STORE_DIR="${root}" pass insert -m "${name}" > /dev/null && PASSWORD_STORE_DIR="${root}" pass generate -ni "${name}" "${password_length}" >/dev/null && PASSWORD_STORE_DIR="${root}" pass edit "${name}" else - insertPass "$menu" + echo $EDITOR + echo -e "PASS\n---\nuser: $user" | PASSWORD_STORE_DIR="${root}" pass insert -m "${group}/${name}" > /dev/null && PASSWORD_STORE_DIR="${root}" pass generate -ni "${group}/${name}" "${password_length}" >/dev/null && PASSWORD_STORE_DIR="${root}" pass edit "${group}/${name}" fi } -#function _rofi () { -# rofi -dmenu -z ${rofiopts} "$@" -#} - help_msg () { echo "rofi-pass (Version: 1.2)" echo "" |