waiting for kodi process to finish [bash]
#1
hello,

iam using kodi for my "smart tv" with my pi 3. I am controlling my pi via Cec (with the remote from the tv). it's working all perfectly, but while kodi runs, my script to steer my mouse is continue running. I've testet it with   wait $(pgrep KODI)   but that didin't worked. Is the a wait command or smething like that?


the piece in my script for starting and waiting for kodi:
 
Quote:                "F3")
                    xdotool key F8
                    ;;
                "F4")
                    kodi
                    sleep 3
                    wait $(pgrep KODI)
                    wait $(pgrep Kodi)
                    wait $(pgrep kodi)
                    wait $(pgrep xbmc)
                    wait $(pgrep XBMC)
                    ;;
                "F1")
                    lxterminal -e 'chromium-browser --start-fullscreen --start-maximized %U'
                    ;;
Reply
#2
The kodi process in linux is usually named kodi.bin (not sure if that is true on Rpi, it is on ubuntu/x86/amd64)
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#3
Generally we have both names in it. kodi and kodi.bin

xml:

davu@Ubuntu-Desktop:~$ ps -u davu | grep -i kodi
 6033 ?        00:00:00 kodi
 6036 ?        00:00:18 kodi.bin
davu@Ubuntu-Desktop:~$

pgrep outputs the PID of the running processes. In that case with Ubuntu (which might differ on RPi) and for Kodi we have 2:

xml:

davu@Ubuntu-Desktop:~$ pgrep kodi
6033
6036
davu@Ubuntu-Desktop:~$

So, if you execute the script in that way (and assuming there are also 2 processes called for RPi as well) the script won't work, because there are two values given to the wait command and therefore it could fail.

Generally I don't get what you are trying to achieve. The wait command simply waits until a process has finished and if you run kodi from command line you also need to put in background to execute further commands. So if you want to wait until the kodi process has finished you have to properly determine which PID it is. This is how it works on Ubuntu:

xml:

davu@Ubuntu-Desktop:~$ kodi 2>/dev/null &
[1] 7223
davu@Ubuntu-Desktop:~$ pgrep kodi
7223
7225
davu@Ubuntu-Desktop:~$
The first command will execute Kodi, direct 'stderr' to /dev/null and put the process in the background

as you can see, we have 2 process IDs. We only need the first one:

xml:

davu@Ubuntu-Desktop:~$ pgrep kodi | head -n1
7223
davu@Ubuntu-Desktop:~$

So the wait command should work like this:

xml:

davu@Ubuntu-Desktop:~$ wait $(pgrep kodi | head -n1)
[1]+  Fertig                  kodi 2> /dev/null
davu@Ubuntu-Desktop:~$

The "Fertig" output comes up after I closed/exited Kodi

Note: that wait command will not work if you open up another shell to execute it, because you will get an error that the PID was not executed from the new shell.

Hope that helps in a bit Wink
Reply
#4
I think you can't solve this problem, because i've not explained excatly what i want.

i want to conrtoll my pi with the tv remote over cec through hdmi.

in the background i'am running this code:

https://paste.ubuntu.com/p/p29NB9vnw3/

This code should do nothing (waiting), while kodi is running, because kodi has his own cec-client build in.
Reply
#5
Hello back,

i've rewritten the code.

Now the problem is to check with an "if" if Kodi is running (instead of wait)i've tried
Quote:if ! pgrep +x "kodi" > /dev/null  #check if Kodi is running
then
      #do cec stuff
else
      #do nothing, because Kodi is running with it's own Cec-client
fi
the code works when i check for "leafpad" (text editor for rpi)

I found a few but they don't work.
(i've found: "kodi" , "kodi.bin" , "xbmc")

looking into the taskmanager is impossible, because I can't leave Kodi while it's open.

What is the process name of Kodi?
Or how can i look it up?
Reply

Logout Mark Read Team Forum Stats Members Help
waiting for kodi process to finish [bash]0