kodi-openbox icon indicating copy to clipboard operation
kodi-openbox copied to clipboard

Kodi not closing when an external app is launched

Open Nadonate opened this issue 4 years ago • 10 comments

Hello!

I'm using the Advance Emulator Launcher to launch an external app (steam). Using kodi-openbox-runprogram with: steam -bigpicture arguments opens my app, but does not exit kodi. When I exit my app, a second instance of kodi is opened so there are 2 running.

How can I get the initial instance of kodi to exit when I launch my external application?

I'm running ubuntu 20, lightdm autologin enabled for my non-root user in the kodi session.

Nadonate avatar Oct 16 '20 13:10 Nadonate

...disregard. I found a solution

editing the kodi-openbox-runprogram.real script to force kodi closed seems to work

kodi forums solution post

Nadonate avatar Oct 16 '20 14:10 Nadonate

Do you mind posting the change you made to the script, in case others have the same issue?

lufinkey avatar Oct 16 '20 14:10 lufinkey

@Nadonate I think I encountered this issue as well, actually. When you launch steam via command, the command exits and steam is launched, rather than the command running until steam exits. If there is some way to keep the command running until steam exits, this will probably fix your issue of a second kodi window popping up.

lufinkey avatar Oct 19 '20 15:10 lufinkey

(sorry for the late response!)

Thanks for the response! I'm still trying to troubleshoot this...

I've edited your runs script based on forum feedback I posted earlier.

I believe this is a less elegent approach, but it works:

#!/bin/bash mkdir -p ~/.kodi-openbox mkdir -p ~/.kodi-openbox/tmp display=$(echo "${DISPLAY}" | tr ':' '_') echo $$ > ~/.kodi-openbox/tmp/program-running.$display kpid=$(cat ~/.kodi-openbox/tmp/session-pid.$display) echo "closing kodi" ps axf | grep kodi.bin | grep -v grep | awk '{print "kill -9 " $1}' | sh echo "running program" eval "$@" eval_result=$? echo "finished running program" exit $eval_result

The issue I am having now, is when steam is launched kodi is not killed and stays running in the background (I can alt-tab between the two)

Nadonate avatar Nov 17 '20 00:11 Nadonate

Ok, I think I found a solution, for my situation atleast.

I added this line to your script:

ps -ef | grep kodi-x11 | grep -v grep | awk '{print $2}' | xargs kill

This should find and close the PID associated with 'kodi-x11'. In testing it works and your script reopens kodi in the openbox session.

I'm not super experienced with scripting, and there is probably a better way to do this, but I'm happy with the result ;).

Thanks again for your work on kodi-openbox, its been perfect in helping me acheive a great HTPC setup! Closing this ticket.

Nadonate avatar Nov 19 '20 18:11 Nadonate

@Nadonate do you mind running Kodi and giving me the path that it's running from? I have a bunch of specific "kodi" commands the script runs through and if it doesn't find the exact path to kodi it just runs the command kodi, which is an issue because this isn't the true kodi executable. Its a shell script that runs the true kodi executable.

I think I usually run into a similar issue when it falls back to the kodi command and that might be the cause, since you're having to manually kill something called kodi-x11

lufinkey avatar Nov 20 '20 03:11 lufinkey

/usr/lib/x86_64-linux-gnu/kodi/kodi-x11

Nadonate avatar Nov 20 '20 12:11 Nadonate

Sorry for the late response but do you mind reverting your changes and trying to add this code to line 95 of kodi-openbox-session?

elif [ -f /usr/lib/x86_64-linux-gnu/kodi/kodi-x11 ]
then
	/usr/lib/x86_64-linux-gnu/kodi/kodi-x11 &
	kpid=$!

I think this should solve your problem

lufinkey avatar Nov 26 '20 00:11 lufinkey

Ok, got around to trying this:

  1. Reverted changes made to kodi-openbox-runprogram.real (luckily I backed up the origional)

  2. Added your suggestion to line 95 of kodi-openbox-session

kodi-OB-edit

Happy to report the changes worked! Everything functions as expeceted; kodi closes, external app launches... when the app closes kodi is resumed.

Thanks for your help!

Nadonate avatar Dec 04 '20 16:12 Nadonate

Hell yeah! I'll add this to the official code and close this out once I do

lufinkey avatar Dec 04 '20 16:12 lufinkey