Delete prompt enhanced to handle encrypted notes. Decrypt note option added.
This commit is contained in:
30
notestorm
30
notestorm
@@ -86,18 +86,24 @@ menulist() {
|
||||
}
|
||||
|
||||
more_menu() {
|
||||
# Options for the submenu go in the options array.
|
||||
declare -a options=(
|
||||
"encrypt" "$(gettext "Encrypt")"
|
||||
# Options for the submenu go in the options array, see options+=
|
||||
declare -a options
|
||||
if [[ "${1##*.}" == "gpg" ]]; then
|
||||
options+=("decrypt" "$(gettext "Decrypt")")
|
||||
else
|
||||
options=("encrypt" "$(gettext "Encrypt")")
|
||||
fi
|
||||
options+=(
|
||||
"delete" "$(gettext "Delete")")
|
||||
local action="$(dialog --backtitle "$(gettext "Use the up and down arrow keys to find the option you want, then press enter to select it.")" \
|
||||
--no-tags \
|
||||
--menu "$(gettext "Please select one")" \
|
||||
0 0 0 ${options[@]} --stdout)"
|
||||
case "$action" in
|
||||
"decrypt") decrypt_note "$1";;
|
||||
"delete") delete_note "$1";;
|
||||
"encrypt") encrypt_note "$1";;
|
||||
"") return;;
|
||||
*) return;;
|
||||
esac
|
||||
}
|
||||
|
||||
@@ -116,9 +122,23 @@ add_note() {
|
||||
fi
|
||||
}
|
||||
|
||||
decrypt_note() {
|
||||
#returns the note to its unencrypted state.
|
||||
if gpg -o "${1%.gpg}" -d "$1" ; then
|
||||
rm -f "$1"
|
||||
infobox "$(gettext "Note decrypted and saved as: ") \"${1%.gpg}\""
|
||||
return
|
||||
fi
|
||||
infobox "$(gettext "Decryption failed.")"
|
||||
}
|
||||
|
||||
delete_note() {
|
||||
local text="$(head -1 "$1")"
|
||||
local answer="$(yesno "$(gettext "Really delete note starting with text") \"$text\"?")"
|
||||
if [[ "${1##*.}" == "gpg" ]]; then
|
||||
local answer="$(yesno "$(gettext "Really delete note named:") \"${1##*/}\"?")"
|
||||
else
|
||||
local answer="$(yesno "$(gettext "Really delete note starting with text:") \"$text\"?")"
|
||||
fi
|
||||
if [ "$answer" == "Yes" ]; then
|
||||
rm -f "$1"
|
||||
infobox "$(gettext "Note deleted.")"
|
||||
|
||||
Reference in New Issue
Block a user