From 74c0d402d56abdde6d3a1ced3029d4ad093abdda Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 3 Aug 2019 13:24:44 -0400 Subject: [PATCH] Stability fixes. If no notes are present the README file is copied over as a note, this causes dialog to not fail on menu generation. If the README isn't found, it creates a message in a file called README.md. --- notestorm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/notestorm b/notestorm index b84b786..003413b 100755 --- a/notestorm +++ b/notestorm @@ -188,6 +188,21 @@ encrypt_note() { infobox "$(gettext "Encryption failed.")" } +original_note() { + # If no notes are present this will try to copy the README.md file into the notes directory so the menu won't fail. + mapfile -t notes < <(find "$xdgPath/notestorm/notes" -type f -iname '*.md' -o -iname '*.gpg') + if [[ "${#notes[@]}" -gt 0 ]]; then + return + fi + if [[ -f "README.md" ]]; then + cp "README.md" "${xdgPath}/notestorm/notes/README.md" + elif [[ -f "/usr/share/doc/notestorm/README.md" ]]; then + cp "README.md" "${xdgPath}/notestorm/notes/README.md" + else + echo "The README file is missing. Pleae visit the notestorm git page for usage information." > "${xdgPath}/notestorm/notes/README.md" + fi +} + # Configuration section # Available arguments in both long and short versions stored in associative array. declare -A argList=( @@ -210,8 +225,9 @@ else pager="${PAGER:-more}" fi xdgPath="${XDG_CONFIG_HOME:-$HOME/.config}" -#set up the notes directory +# set up the notes directory mkdir -p "${xdgPath}/notestorm/notes" +original_note # Keep track of the number of arguments passed to the program. argNum=$# # Settings to improve accessibility of dialog.