Browse Source

exit program when pressing cancel; adding pronouncable password generation

master
mxmehl 3 years ago
parent
commit
7008ba72bf
1 changed files with 25 additions and 5 deletions
  1. +25
    -5
      gpassgen.sh

+ 25
- 5
gpassgen.sh View File

@@ -23,29 +23,49 @@
#
########################################################################

function checkexit {
if [ $1 = 1 ]; then exit 1; fi
}

cd "$(dirname "$(readlink -f "$0")")"

if [ $(zenity --question --cancel-label "More options" --ok-label "Close" --text "$(apg -m 16 -M NCL -a 1)" --title "Generated Passwords"; echo $?) == 1 ]; then
# More options requested
echo $POPT
PLEN=$(zenity --entry --text "Desired length of password(s)" --title "Enter password length")
checkexit $?
PALG=$(zenity --list \
--text="Choose between random character or pronouncable passwords" \
--title="Choose password algorithm" \
--column="Option" --column="Description" \
1 "Random character passwords" \
0 "Pronouncable password algorithm" \
)
checkexit $?
PALG=$(echo $PALG | sed 's/|//g')
POPT=$(zenity --list --multiple \
--text="Choose one or multiple generator options" \
--title="Choose password options" \
--column="Option" --column="Description" \
--text="Choose one or multiple generator options" \
--title="Choose password options" \
--column="Option" --column="Description" \
N "Numerical" \
C "Capital letters" \
L "Lower case letters" \
)
checkexit $?
POPT=$(echo $POPT | sed 's/|//g')
PAMT=$(zenity --entry --text "Desired amount of generated passwords" --title "Enter password amount")
checkexit $?
# Set defaults if no entry was given
if [ "$PLEN" == "" ]; then
PLEN="12"
fi
if [ "$PALG" == "" ]; then
PLEN="1"
fi
if [ "$POPT" == "" ]; then
POPT="NCL"
fi
@@ -54,5 +74,5 @@ if [ $(zenity --question --cancel-label "More options" --ok-label "Close" --text
fi
# Output desired passwords
$(zenity --info --text "$(apg -a 1 -m $PLEN -M $POPT -n $PAMT)" --title "Generated Passwords")
$(zenity --info --text "$(apg -a $PALG -m $PLEN -M $POPT -n $PAMT)" --title "Generated Passwords")
fi

Loading…
Cancel
Save