Wake.py not being run

Hi

I’ve had my Vero V in use for a couple weeks now, and I am still trying to get it to work like the KODI box I used before, but i’m still not entirely there.

One of the things is that since the Vero boxes does not shut down completely, I can’t use the “Scan library on startup” functionality and have tried to get it to work by using wake.py, which a couple of people on the forums here have mentioned, but I just can’t seem to get it to work.

I’ve created wake.py in /home/osmc/.kodi/userdata with permissions 0755/-rwxr-xr-x, and it currently contains the following script:

import xbmc
xbmc.executebuiltin('XBMC.System.Exec(touch /home/osmc/wake_debug)')
xbmc.executebuiltin('XBMC.ActivateWindow(home)')
xbmc.sleep(5000)
xbmc.executebuiltin('XMBC.CECActivateSource')
xbmc.sleep(250)
xbmc.executebuiltin('XBMC.UpdateLibrary(video)')

Debug log below

2025-01-01 19:47:01.243 T:7998     info <general>: CApplication::ToggleStandby -- checking for existence of /home/osmc/.kodi/userdata/wake.py
2025-01-01 19:47:01.243 T:7998     info <general>: CApplication::ToggleStandby -- script /home/osmc/.kodi/userdata/wake.py found
2025-01-01 19:47:01.243 T:8208    debug <general>: Thread LanguageInvoker start, auto delete: false
2025-01-01 19:47:01.244 T:7998    debug <general>: [threads] name: 'LanguageInvoker' priority: '3'
2025-01-01 19:47:01.244 T:7998    debug <general>: HandleKey: 11 (0xb, obc244) pressed, window 10000, action is Select
2025-01-01 19:47:01.244 T:7998    debug <general>: Activating window ID: 10025
2025-01-01 19:47:01.251 T:8208    debug <general>: initializing python engine.
2025-01-01 19:47:01.251 T:8208    debug <general>: CPythonInvoker(11, /home/osmc/.kodi/userdata/wake.py): start processing
2025-01-01 19:47:01.434 T:8208    debug <general>: -->Python Interpreter Initialized<--
2025-01-01 19:47:01.434 T:8208    debug <general>:
2025-01-01 19:47:01.434 T:8208    debug <general>: CPythonInvoker(11, /home/osmc/.kodi/userdata/wake.py): the source file to load is "/home/osmc/.kodi/userdata/wake.py"
2025-01-01 19:47:01.434 T:8208  warning <general>: CPythonInvoker(11): Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11): full python path:
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):   custom python path:
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /home/osmc/.kodi/addons/script.module.exifread/lib
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /home/osmc/.kodi/addons/script.module.iptcinfo3/lib
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /home/osmc/.kodi/addons/script.module.simpleeval/lib
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /home/osmc/.kodi/addons/script.module.unidecode/lib
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /home/osmc/.kodi/addons/script.module.xmltodict/lib
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /home/osmc/.kodi/userdata
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/share/kodi/addons/script.module.osmccommon/resources/lib/
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/share/kodi/addons/script.module.osmcsetting.apfstore/resources/lib/
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/share/kodi/addons/script.module.osmcsetting.logging/resources/lib/
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/share/kodi/addons/script.module.osmcsetting.networking/resources/lib/
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/share/kodi/addons/script.module.osmcsetting.remotes/resources/lib/
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/share/kodi/addons/script.module.osmcsetting.services/resources/lib/
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/share/kodi/addons/script.module.osmcsetting.updates/resources/lib/
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/share/kodi/addons/script.module.pil/lib
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/share/kodi/addons/script.module.pycryptodome/lib
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):   default python path:
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/lib/python39.zip
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/lib/python3.9
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/lib/python3.9/lib-dynload
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/local/lib/python3.9/dist-packages
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):     /usr/lib/python3/dist-packages
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11): adding args:
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11):
2025-01-01 19:47:01.435 T:8208    debug <general>: CPythonInvoker(11, /home/osmc/.kodi/userdata/wake.py): entering source directory /home/osmc/.kodi/userdata
2025-01-01 19:47:01.505 T:7998    debug <general>: ------ Window Deinit (Home.xml) ------
2025-01-01 19:47:01.505 T:7998    debug <general>: FreeVisualisation() done
2025-01-01 19:47:01.523 T:7998    debug <general>: ------ Window Init (MyVideoNav.xml) ------
2025-01-01 19:47:01.525 T:7998    debug <general>: CGUIMediaWindow::GetDirectory (library://video/movies/)
2025-01-01 19:47:01.525 T:7998    debug <general>:   ParentPath = [smb://x.x.x.x/xxxxxxxxxx/]
2025-01-01 19:47:01.585 T:8207    debug <CWebserver[80]>: request received for /jsonrpc
2025-01-01 19:47:01.607 T:8209    debug <general>: Skipped 2 duplicate messages..
2025-01-01 19:47:01.607 T:8209    debug <general>: Thread BackgroundLoader start, auto delete: false
2025-01-01 19:47:01.607 T:7998    debug <general>: [threads] name: 'BackgroundLoader' priority: '3'
2025-01-01 19:47:01.617 T:8209    debug <general>: Thread BackgroundLoader 3212833024 terminating
2025-01-01 19:47:01.635 T:7998    debug <general>: ToggleDeviceState - waking up CEC device...
2025-01-01 19:47:01.635 T:7998    debug <general>: using python screensaver add-on screensaver.picture.slideshow
2025-01-01 19:47:01.635 T:7998    debug <general>: CPythonInvoker(10, /home/osmc/.kodi/addons/screensaver.picture.slideshow/default.py): trigger Monitor abort request
2025-01-01 19:47:01.639 T:8059    debug <general>: started alarm with name: sssssscreensaver
2025-01-01 19:47:01.751 T:8206    debug <CWebserver[80]>: request received for /jsonrpc
2025-01-01 19:47:02.492 T:8187    debug <general>: Skipped 2 duplicate messages..
2025-01-01 19:47:02.492 T:8187    debug <general>: screensaver.picture.slideshow: script stopped
2025-01-01 19:47:02.492 T:8187    debug <general>: CPythonInvoker(10, /home/osmc/.kodi/addons/screensaver.picture.slideshow/default.py): script successfully run
2025-01-01 19:47:02.492 T:8187     info <general>: CPythonInvoker(10, /home/osmc/.kodi/addons/screensaver.picture.slideshow/default.py): waiting on thread 3904884992
2025-01-01 19:47:02.592 T:8187    debug <general>: onExecutionDone(10, /home/osmc/.kodi/addons/screensaver.picture.slideshow/default.py)
2025-01-01 19:47:02.593 T:8187    debug <general>: .
2025-01-01 19:47:02.645 T:8187    debug <general>: Python interpreter interrupted by user
2025-01-01 19:47:02.645 T:7998    debug <general>: CPythonInvoker(10, /home/osmc/.kodi/addons/screensaver.picture.slideshow/default.py): script termination took 1011ms
2025-01-01 19:47:02.645 T:8187    debug <general>: Thread LanguageInvoker 3232755968 terminating
2025-01-01 19:47:03.248 T:8011    debug <general>: CWinSystemAmlogic: Detected HDMI switch
2025-01-01 19:47:03.275 T:8201    debug <CWebserver[80]>: request received for /jsonrpc
2025-01-01 19:47:03.499 T:8011    debug <general>: Skipped 5 duplicate messages..
2025-01-01 19:47:03.499 T:8011    debug <general>: CWinSystemAmlogic: Detected HDMI switch
2025-01-01 19:47:06.686 T:8208    debug <general>: Skipped 3 duplicate messages..
2025-01-01 19:47:06.686 T:8208    debug <general>: CPythonInvoker(11, /home/osmc/.kodi/userdata/wake.py): script successfully run
2025-01-01 19:47:06.686 T:8208    debug <general>: onExecutionDone(11, /home/osmc/.kodi/userdata/wake.py)
2025-01-01 19:47:06.697 T:8208    debug <general>: Python interpreter stopped

As far as I can tell it detects the script, says it runs it, but none of the things in the script is actually being run.

It doesn’t touch the file (which I added just for debugging), but it also doesn’t switch to the home section, activates CEC or updates the library.

What am I missing?

Surely you would need to specify full path (/usr/bin/touch)?
Try adding the Python shebang?

I can’t test further until tomorrow, but i’ll try adding the full path to the touch binary.

Is a shebang really needed? I was of the understanding that the wake.py script is run “inside” the kodi environment, and not in a shell?

It’s been so long since I implemented this feature so I don’t recall.

I’d say probably not (re shebang).

Hi, afaIk you should only call scripts using function System.Exec. So this worked at once on first test:

wake.py

import xbmc
xbmc.executebuiltin('System.Exec(/home/osmc/.kodi/userdata/myscript.sh)')

myscript.sh (don’t forget to set appropriate exec permissions)

!#/bin/bash
touch /home/osmc/wake_debug

(Just to be sure: wake.py is only fired when the mediacenter wakes up from being suspended.)

1 Like

Thanks @JimKnopf, that seemed to do the trick.

I removed the XBMC. prefixes on the commands, and now KODI seems to do what I ask :slight_smile:

Now I just have to find out how to activate the Movies section on the Home screen when waking up, looks like I have to dive into the skin code to find IDs and whatnot, but at least the wake.py script is now being run.

With the OSMC skin you can see the required actions at Settings -> Interface -> Skin -> Configure Skin -> General -> Customize main menu -> Movies on the right side at change action:

That requires the change of the wake.py script to

import xbmc
xbmc.executebuiltin('System.Exec(/home/osmc/.kodi/userdata/myscript.sh)')
xbmc.executebuiltin('ActivateWindow(videos,videodb://movies/titles/,return)')

Addition regarding Kodi:
List of Builtin Functions
Window IDs

1 Like

“Unfortunately” I am using the default Estuary skin, been using it for years and just prefer how it looks, but your suggesting gave me something to work on.

But most importantly, the wake.py script works now, turns on my TV via CEC (which for some reason stopped working with the Vero box, my AVR turns on fine enough), and the library updates, so everythings good :slight_smile:

There is no change necessary for skin Estuary.

1 Like

Indeed there isn’t, perfect, thanks a bunch

1 Like