exit program when pressing cancel; adding pronouncable password generation
This commit is contained in:
+22
-2
@@ -23,14 +23,28 @@
|
|||||||
#
|
#
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
|
function checkexit {
|
||||||
|
if [ $1 = 1 ]; then exit 1; fi
|
||||||
|
}
|
||||||
|
|
||||||
cd "$(dirname "$(readlink -f "$0")")"
|
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
|
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
|
# More options requested
|
||||||
echo $POPT
|
|
||||||
PLEN=$(zenity --entry --text "Desired length of password(s)" --title "Enter password length")
|
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 \
|
POPT=$(zenity --list --multiple \
|
||||||
--text="Choose one or multiple generator options" \
|
--text="Choose one or multiple generator options" \
|
||||||
--title="Choose password options" \
|
--title="Choose password options" \
|
||||||
@@ -39,13 +53,19 @@ if [ $(zenity --question --cancel-label "More options" --ok-label "Close" --text
|
|||||||
C "Capital letters" \
|
C "Capital letters" \
|
||||||
L "Lower case letters" \
|
L "Lower case letters" \
|
||||||
)
|
)
|
||||||
|
checkexit $?
|
||||||
POPT=$(echo $POPT | sed 's/|//g')
|
POPT=$(echo $POPT | sed 's/|//g')
|
||||||
|
|
||||||
PAMT=$(zenity --entry --text "Desired amount of generated passwords" --title "Enter password amount")
|
PAMT=$(zenity --entry --text "Desired amount of generated passwords" --title "Enter password amount")
|
||||||
|
checkexit $?
|
||||||
|
|
||||||
# Set defaults if no entry was given
|
# Set defaults if no entry was given
|
||||||
if [ "$PLEN" == "" ]; then
|
if [ "$PLEN" == "" ]; then
|
||||||
PLEN="12"
|
PLEN="12"
|
||||||
fi
|
fi
|
||||||
|
if [ "$PALG" == "" ]; then
|
||||||
|
PLEN="1"
|
||||||
|
fi
|
||||||
if [ "$POPT" == "" ]; then
|
if [ "$POPT" == "" ]; then
|
||||||
POPT="NCL"
|
POPT="NCL"
|
||||||
fi
|
fi
|
||||||
@@ -54,5 +74,5 @@ if [ $(zenity --question --cancel-label "More options" --ok-label "Close" --text
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Output desired passwords
|
# 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
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user