Script directory and additional Main Menu action


i have two questions…

  1. I want to perform a script when the system goes in suspend mode. In LibreELEC there is a sleep.d directory for such scripts. Is it in OSMC also possible to perfor a script when switching in suspend mode?

  2. It is possible to perform a shell command (or script) additional when i select a certain main menu button (select “PVR & Live TV” button -> perform default ActivateWindow(TVGuide) + shell command or script)?

Thanks in advance!


  1. See [HOWTO] Vero 4K / 4K: Performing actions programatically on Standby and Wakeup

  2. Yes, you could write a Python script and map it to be invoked. The easiest way would be with Keymap Editor

Keymap editor does not support calling any scripts. If you open that add-on it will actually destroy any that were manually created. Furthermore the use case being asked about, invoking an additional action when a main menu item is selected, is not something that can be affected with a keymap anyway. AFAIK this is something that would have to be done by customising a skin.

If someone wanted to make a custom button on their remote to perform the function they could do this manually by putting everything in an external script (you can only map a single action to a key) and keymapping to that. In the script they could use a kodi-send --action="ActivateWindow(TVGuide)" to bring up that menu along with whatever else their doing with the script.

Thanks for your replies!

The additional command or skript should only kill the process that holds the network connection to the tvheadend server. Now i have seen that this process is unfortunately the kodi process itself:

osmc@osmc:~$ sudo netstat -pn | grep
tcp        0      0      ESTABLISHED 2562/kodi.bin

What would you recommend to stop this network connection, maybe stop and start the tvheadend client addon via a command on suspend and wakeup?

I need to stop this network connection in suspend, otherwise my tvheadend server (other machine) is running all the time and can’t switch to suspend itself.

You can use connmanctl to disable the used technology (Ethernet or wifi) and re-enable afterwards.

Unfortunately i have currently no python knowledge at all but will learn the basics if it is necessary for further adjustments.

Can you tell me how i can run the connmanctl command in a phyton script?

osmc@osmc:~/.kodi/userdata$ cat
import xbmc
#sudo etherwake
sudo connmanctl enable ethernet
osmc@osmc:~/.kodi/userdata$ python
  File "", line 4
    sudo connmanctl enable ethernet
SyntaxError: invalid syntax

Hi Try:

import xbmc
import os

#sudo etherwake
os.system('sudo connmanctl enable ethernet')

Thanks Tom.