diff --git a/jarvis-functions.sh b/jarvis-functions.sh index 80c9a4b..7973941 100644 --- a/jarvis-functions.sh +++ b/jarvis-functions.sh @@ -40,7 +40,7 @@ LISTEN_COMMAND () { PLAY sounds/timeout.wav sleep 1 # BUG here despite timeout mic still busy can't rec again... bypass=false - source hooks/exiting_cmd + $jv_json || source hooks/exiting_cmd # don't trigger hooks if API order='' # clean previous order commands="$(jv_get_commands)" # in case we were in nested commands break 2 diff --git a/jarvis.sh b/jarvis.sh index 81199d0..8491d16 100755 --- a/jarvis.sh +++ b/jarvis.sh @@ -438,6 +438,9 @@ EOM exit fi +# don't trigger hooks from API +$jv_json || source hooks/program_startup + # if -s argument provided, just say it & exit (used in jarvis-events) if [[ "$just_say" != false ]]; then say "$just_say" @@ -490,8 +493,6 @@ if [ "$just_execute" == false ]; then fi fi -source hooks/program_startup - # Include installed plugins shopt -s nullglob for f in plugins/*/config.sh; do source $f; done # plugin configuration diff --git a/utils/utils.sh b/utils/utils.sh index 13b68e0..8299973 100644 --- a/utils/utils.sh +++ b/utils/utils.sh @@ -259,10 +259,14 @@ jv_kill_jarvis () { jv_exit () { local return_code=${1:-0} - $verbose && jv_debug "DEBUG: program exit handler" - source hooks/program_exit $return_code - - $jv_json && echo "]" + # If using API, terminate json table output + if $jv_json; then + echo "]" + else + # If not using API, trigger program exit hook + $verbose && jv_debug "DEBUG: program exit handler" + source hooks/program_exit $return_code + fi # termine child processes (ex: HTTP Server from Jarvis API Plugin) local jv_child_pids="$(jobs -p)" @@ -271,7 +275,7 @@ jv_exit () { fi # make sure the lockfile is removed when we exit and then claim it - #[ "$(cat $lockfile)" == $$ ] && rm -f $lockfile # to test tested further + #[ "$(cat $lockfile)" == $$ ] && rm -f $lockfile # to be tested further #[ "$just_execute" == false ] && rm -f $lockfile # https://github.com/alexylem/jarvis-api/issues/3 exit $return_code } diff --git a/version.txt b/version.txt index 9e8a855..0b066d9 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -17.01.26 +17.02.04