make --root totally optional when not splitting passwords

This commit is contained in:
Rasmus Steinke 2015-07-14 20:58:23 +02:00
parent 2514370379
commit 0f46c638d3

View File

@ -26,19 +26,22 @@ fi
if [[ -n "$2" ]]; then if [[ -n "$2" ]]; then
root="$2" root="$2"
else
root=""
fi fi
get_root () { #get_root () {
if [[ -n "$2" ]]; then # if [[ -n "$2" ]]; then
root="$2" # root="$2"
else # else
if [[ $(find "$basedir" -maxdepth 1 \( ! -name '.*' \) -type d | wc -l) == "1" ]]; then # if [[ $(find "$basedir" -maxdepth 1 \( ! -name '.*' \) -type d | wc -l) == "1" ]]; then
root="$(find "${basedir}" -maxdepth 1 \( ! -name '.*' \) -type d -exec basename {} \;)" # root="$(find "${basedir}" -maxdepth 1 \( ! -name '.*' \) -type d -exec basename {} \;)"
else # else
root=$(find "${basedir}" -maxdepth 1 \( ! -name '.*' \) -type d -exec basename {} \; | rofi -dmenu -p "Choose Database") # root=$(find "${basedir}" -maxdepth 1 \( ! -name '.*' \) -type d -exec basename {} \; | rofi -dmenu -p "Choose Database")
fi # fi
fi # root="${basedir}"
} # fi
#}
list_passwords() { list_passwords() {
passwords=( ~/.password-store/**/*.gpg ) passwords=( ~/.password-store/**/*.gpg )
@ -58,12 +61,12 @@ xdotool_type() {
} }
mainMenu () { mainMenu () {
if [[ -z "$root" ]]; then # if [[ -z "$root" ]]; then
get_root # get_root
fi # fi
if [[ -n "$2" ]]; then # if [[ -n "$2" ]]; then
root="$2" # root="$2"
fi # fi
if [[ $1 == "manage" ]]; then if [[ $1 == "manage" ]]; then
HELP="<span color='$help_color'>${edit}: Edit Entry | ${move}: Move Entry | ${delete}: Delete Entry | ${show}: Show Entry</span>" HELP="<span color='$help_color'>${edit}: Edit Entry | ${move}: Move Entry | ${delete}: Delete Entry | ${show}: Show Entry</span>"
selected_password="$(echo -e "0 Return to Main Menu\n---\n$(list_passwords 2>/dev/null)" | rofi -custom-kb-1 "${edit}" -custom-kb-2 "${move}" -custom-kb-3 "${delete}" -custom-kb-4 "${show}" -mesg "${HELP}" -dmenu -select "$entry" -p "rofi-pass > ")" selected_password="$(echo -e "0 Return to Main Menu\n---\n$(list_passwords 2>/dev/null)" | rofi -custom-kb-1 "${edit}" -custom-kb-2 "${move}" -custom-kb-3 "${delete}" -custom-kb-4 "${show}" -mesg "${HELP}" -dmenu -select "$entry" -p "rofi-pass > ")"