Skip to content

Commit

Permalink
Update 022321 5
Browse files Browse the repository at this point in the history
Updates for Close Kodi option for external launching
  • Loading branch information
zach-morris committed Feb 23, 2021
1 parent e500e3c commit e3c8b25
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
32 changes: 16 additions & 16 deletions resources/bin/applaunch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ then
KODI_BIN_LINUX="kodi"
fi

#Sleep to let Kodi write to log and whatnot prior to shutdown
sleep 1
#Sleep to let Kodi write to log, IAGL to complete, and whatnot prior to shutdown
sleep 1s

#Start OSX Exit
if ! [ -z $KODI_PID_DARWIN ]
Expand All @@ -50,7 +50,7 @@ then
echo "Attempting to exit Kodi via JSONRPC"
JSON_RPC_COMMAND=$(curl -s --data-binary '{"jsonrpc": "2.0", "method": "Application.Quit", "id":1}' -H 'content-type: application/json;' http://127.0.0.1:8080/jsonrpc)
# Wait for the quit
sleep 5
sleep 5s
if ! [ -z $JSON_RPC_COMMAND ]
then
if ! [[ $JSON_RPC_COMMAND == *"$RPC_RESULT"* ]]
Expand All @@ -71,13 +71,13 @@ then
echo "JSONRPC exit failed, attempting SIGHUP"
kill -s SIGHUP $KODI_PID_DARWIN
# Wait for the quit
sleep 2
sleep 2s
if ps -p $KODI_PID_DARWIN > /dev/null
then
echo "SIGHUP exit failed, attempting SIGKILL"
kill -s SIGKILL $KODI_PID_DARWIN
# Wait for the kill
sleep 2
sleep 2s
if ! ps -p $KODI_PID_DARWIN > /dev/null
then
echo "SIGKILL Exit Success"
Expand Down Expand Up @@ -110,7 +110,7 @@ then
echo "Attempting to exit Kodi via JSONRPC"
JSON_RPC_COMMAND=$(curl -s --data-binary '{"jsonrpc": "2.0", "method": "Application.Quit", "id":1}' -H 'content-type: application/json;' http://127.0.0.1:8080/jsonrpc)
# Wait for the quit
sleep 5
sleep 5s
if ! [ -z $JSON_RPC_COMMAND ]
then
if ! [[ $JSON_RPC_COMMAND == *"$RPC_RESULT"* ]]
Expand All @@ -126,13 +126,13 @@ then
echo "JSONRPC exit failed, attempting SIGHUP"
kill -s SIGHUP $KODI_PID_LINUX_STANDALONE
# Wait for the quit
sleep 2
sleep 2s
if ps -p $KODI_PID_LINUX_STANDALONE > /dev/null
then
echo "SIGHUP exit failed, attempting SIGKILL"
kill -s SIGKILL $KODI_PID_LINUX_STANDALONE
# Wait for the kill
sleep 2
sleep 2s
if ! ps -p $KODI_PID_LINUX_STANDALONE > /dev/null
then
echo "SIGKILL Exit Success"
Expand All @@ -157,7 +157,7 @@ then
echo "Attempting to exit Kodi via JSONRPC"
JSON_RPC_COMMAND=$(curl -s --data-binary '{"jsonrpc": "2.0", "method": "Application.Quit", "id":1}' -H 'content-type: application/json;' http://127.0.0.1:8080/jsonrpc)
# Wait for the quit
sleep 5
sleep 5s
if ! [ -z $JSON_RPC_COMMAND ]
then
if ! [[ $JSON_RPC_COMMAND == *"$RPC_RESULT"* ]]
Expand All @@ -173,13 +173,13 @@ then
echo "JSONRPC exit failed, attempting SIGHUP"
kill -s SIGHUP $KODI_PID_LINUX_X11
# Wait for the quit
sleep 2
sleep 2s
if ps -p $KODI_PID_LINUX_X11 > /dev/null
then
echo "SIGHUP exit failed, attempting SIGKILL"
kill -s SIGKILL $KODI_PID_LINUX_X11
# Wait for the kill
sleep 2
sleep 2s
if ! ps -p $KODI_PID_LINUX_X11 > /dev/null
then
echo "SIGKILL Exit Success"
Expand All @@ -203,7 +203,7 @@ then
echo "Attempting to exit Kodi via JSONRPC"
JSON_RPC_COMMAND=$(curl -s --data-binary '{"jsonrpc": "2.0", "method": "Application.Quit", "id":1}' -H 'content-type: application/json;' http://127.0.0.1:8080/jsonrpc)
# Wait for the quit
sleep 5
sleep 5s
if ! [ -z $JSON_RPC_COMMAND ]
then
if ! [[ $JSON_RPC_COMMAND == *"$RPC_RESULT"* ]]
Expand All @@ -219,13 +219,13 @@ then
echo "JSONRPC exit failed, attempting SIGHUP"
kill -s SIGHUP $KODI_PID_LINUX
# Wait for the quit
sleep 2
sleep 2s
if ps -p $KODI_PID_LINUX > /dev/null
then
echo "SIGHUP exit failed, attempting SIGKILL"
kill -s SIGKILL $KODI_PID_LINUX
# Wait for the kill
sleep 2
sleep 2s
if ! ps -p $KODI_PID_LINUX > /dev/null
then
echo "SIGKILL Exit Success"
Expand Down Expand Up @@ -255,7 +255,7 @@ then
then
#Something is wrong because it all happened too fast
echo "There was likely an error while launching, waiting 10 seconds before restarting Kodi"
sleep 10
sleep 10s
fi
# Done? Restart Kodi
sleep 1
Expand All @@ -270,7 +270,7 @@ then
nohup $KODI_BIN_LINUX &
fi
#Attempt to restart IAGL after relaunching Kodi
sleep 3
sleep 5s
RESTART_IAGL_RPC_COMMAND=$(curl -s --data-binary '{"jsonrpc": "2.0", "method": "Addons.ExecuteAddon", "params": { "addonid": "plugin.program.iagl" }, "id":1}' -H 'content-type: application/json;' http://127.0.0.1:8080/jsonrpc)
echo "JSONRPC response to restart IAGL was $RESTART_IAGL_RPC_COMMAND"
else
Expand Down
3 changes: 2 additions & 1 deletion resources/lib/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ def launch(self,launch_files=None,**kwargs):
t = Thread(target=enqueue_output, args=(launch_process.stdout, q))
t.daemon = True # thread dies with the program
t.start()
xbmc.sleep(WAIT_FOR_PLAYER_TIME)

if not self.settings.get('ext_launchers').get('close_kodi') and capture_launch_log:
xbmc.sleep(WAIT_FOR_PLAYER_TIME)
while True:
try:
current_line = q.get_nowait()
Expand Down
2 changes: 1 addition & 1 deletion run_IAGL_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
wait = False
break
xbmc.sleep(3000)
if any([y in addons_available for y in [x for x in RP_DEFAULTS.get(game_list_id) if x] if y]):
if addons_available and any([y in addons_available for y in [x for x in RP_DEFAULTS.get(game_list_id) if x] if y]):
current_command = next(iter([y for y in [x for x in RP_DEFAULTS.get(game_list_id) if x] if y in addons_available]),'none')
if iagl_addon_wizard.game_lists.update_game_list_header(game_list_id,header_key='emu_launcher',header_value='retroplayer',confirm_update=False):
xbmc.log(msg='IAGL: Wizard update launcher for game list %(value)s to Retroplayer'%{'value':game_list_id}, level=xbmc.LOGDEBUG)
Expand Down

0 comments on commit e3c8b25

Please sign in to comment.