exit program when pressing cancel; adding pronouncable password generation
This commit is contained in:
+25
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user