How to make kodi exit when CEC shutdown command rececived

I would like kodi to exit when the CEC shutdown command is received so I can run a program to wait for CEC commands and then restart kodi when CEC device starts up. This way I can leave device connected on network. In the settings for peripherals/input I changed CEC shutdown command from shutdown to quit but when I ssh I see kodi is still running.

I’m sure you know the /storage/.config/autostart.sh script that runs before starting kodi.

In the same way there is the script /storage/.config/shutdown.sh. In this case I do not know the environment in which it runs (kodi status, network status, …)

Perhaps this will help you although you will have to look for more information. Look first at https://wiki.libreelec.tv/autostart.sh

Thanks for that. No I did not know about the autostart command. Anyhow, I added something to the shutdown.sh but this isn’t called because I don’t think that kodi is exiting.

It doesn’t seem to be possible using the normal libcec plugin because the QUIT message is disabled in xbmc/Application.cpp

I don’t understand why you want this. You can just leave your device running Kodi.

1 Like

Because when the TV is switched on again it doesn’t go back to the same action as before. So sure kodi can stop playback and should not consume power but it doesn’t set the TV back to the CEC input. This confuses the users that expect the TV to act like a TV.

What is a bit hard to understand is why the change is made in Application.cpp yes the CEC library still sends the QUIT message. It seems a little confusing to leave that in there, don’t you think?

It is working here as expected. When I turn off the TV my N2 goes into suspend. If I turn it on N2 starts immediately.
Even if I have a video paused it will return to a paused video.

Don’t know what you else want. If you want your device to run permanently you don’t need to exit Kodi cause it will not safe you any energy.

You also lost me with Application.cpp. You need to be more specific. Share some links to GitHub Code when you want to discuss it.

In the patch added in commit commit e31325bb97d9788cfd1c188d88fc7bc48e72b601

which does:

kodi: SIGTERM patch: do not delay shutdown

From 332f8f5c552f695d4e893512a642f9f9bbed6d9e Mon Sep 17 00:00:00 2001
From: MilhouseVH milhouseVH.github@nmacleod.com
Date: Tue, 19 Mar 2019 18:06:56 +0000
Subject: [PATCH] handle SIGTERM

  1. CApplication::Stop cant be trusted. (deadlocks crashes and boo)

so, when shutdown/reboot is requested:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.