I am trying to make a mac Clippy in bash. Here is some of my code:
say "Hello there!"
declare -a assist_array=()
while true; do
if pgrep -xq -- "Mail"; then
assist_array+=('It looks like your trying to send an email. Would you like some help?')
fi
if pgrep -xq -- "Notes"; then
assist_array+=('It looks like your trying to take a note. Would you like some help?')
fi
arraylength=${#assist_array[@]}
for (( i=0; i<${arraylength}+1; i++ )); do
echo ${assist_array[i]}
say ${assist_array[i]}
assist_array=()
done
done
When I have Mail open, it echos and says: "It looks like your trying to send an email. Would you like some help?" then a new line. I have both Mail and Notes open. How can I make it so it continues to scan for open apps and not get stuck in the for loop?