Turn TV off, exit OSMC

So I want to achieve the following. When I turn off my TV, I want Kodi to stop. So basically a headless Pi 4.

I normally boot up kodi with SSH: sudo systemctl start mediacenter. When I set the exit setting when TV goes off in CEC, I can see that Kodi shuts down by using the top command in SSH. But after a few seconds it starts kodi.bin again. Is there a way to disable that?

You can disable this in the watchdog, but will need to re-apply it every update.

Where can I find this watchdog?


Thanks for helping. Found the file, but I can’t read code that well. What line should I disable?

@sam_nazarko sorry to bother you again. But do you know what I need to adjust in that file?

You should remove the loop that restarts Kodi.
Look for the line ‘exited with’.

Keep in mind this is changing core functionality and is not supported.

The only line with ‘exited with’ is this one: echo "Kodi exited with return code $CODE after $hours hours, $minutes minutes and $seconds seconds"

Disabling that line does not do anything. I guess this goes over my head. Tried disabling some other lines, but that did not work either.

But basically the ‘Exit’ option within Kodi should not be named exit, because it does not really exit kodi, but it makes a restart. So that option is confusing. Maybe we could have an option somewhere so the user can choose that exit is really exiting Kodi.

It exit Kodi and goes to Terminal if you press ESC within 1 minute.

@sam_nazarko wrote

Which I assume would be the while true; do in line 98 with the corresponding done in line 142

But as @sam_nazarko you are on your own with this.

Thanks. I will try. But otherwise I have a workaround. I’ll ping my TV if it’s off, and stop Kodi that way.

It worked, but a lot of code seems to be disabled that way. I’ll have a look what method I’ll use.