# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# By default this script does nothing.
su - osmc -c "/usr/bin/python /home/osmc/texturecache.py @logfile= @xbmc.host=localhost @bin.tvservice=/opt/vc/bin/tvservice rbphdmi &"
Any suggestions VERY MUCH appreciated.
EDIT: I’m having some luck with systemd. The only problem is I need the service to start after Kodi has loaded. Right now I have this:
You could make sure it starts after the Mediacenter service by adding mediacenter.service to your After line in the Unit section, but that doesn’t mean that Kodi has finished starting up, it just means that /usr/bin/mediacenter (the script that runs and monitors Kodi) has started.
If Kodi must be fully up and running to the home screen before you run your script you’re kind of in trouble - because there is no simple way to do that in a service definition.
You would have to probe/query Kodi using json rpc or something similar in a sleep loop to find out when it has finished starting up, or… just put a big delay and hope for the best…
I opted for the big delay. Seems to be working alright so far.
Only problem I’ve noticed is it seems to be using this method to turn off HDMI:
This is not an addon or a screensaver, it’s a script (daemon) that monitors JSON notifications and when it sees that the screensaver has been activated it starts a timer that will, when it elapses (default 900 seconds), remove HDMI power with a call to “tvservice --off”.
If the screensaver is deactivated before the timer has elapsed, the timer is cancelled and the system continues normally.
When the screensaver is deactivated through user activity and HDMI power is off, the HDMI power will be restored (tvservice --preferred) followed by a JSON call to Application.Quit() so that XBMC terminates and is automatically restarted - not rebooted - and the EGL context restored. This takes about 15 seconds from deactivating the screensaver to the menu re-appearing on a 1GHz Pi running a nightly build of OpenELEC Gotham.
But when I run texturecache.py from the command line it uses this updated method:
When using Raspberry Pi firmware from 23 May 2014 onwards (check with vcgencmd version), “vcgencmd display_power 0” and “vcgencmd display_power 1” will be used to disable/enable HDMI as this method does NOT require xbmc.bin to be restarted. See this post for further details.
I’m not sure what difference the method of starting the script effects how the script runs, but that seems to be what’s happening in my case.
texturecache.py script can be found here if anyone wants to take a look at it.
If everything works right, the texturecache.timer waits 60 seconds after boot, then starts texturecache.service, which runs texturecache.py! This is my first time working with systemd so if you see something that needs fixing, please post it so I can fix mine.
I spent a few hours trying to figure this solution out on an old TV that has poor CEC support; the normal CEC standby and wake settings in kodi would never put my TV into standby. Once I found this post, I was implemented, tested, and happy within about 10 minutes. This is something that should be built into RPi versions of Kodi or at least OSMC.