Script not running from within Kodi

So I am trying to get the RPi 2 to turn on/off the video output via the remote. So to do this, I created a keyboard.xml and added the required key maps to it. I am aware that .sh scripts are not working in OSMC, so I added a link to a .py which then uses to call the .sh script. All scripts have correct permissions and have been made executable.

So I ran a test that called a which called a that just appended “OK” to a .txt file. This worked 100% correctly from within Kodi on a keypress, over SSL and via command line.

So I tried doing the exact same thing with the HDMI script. It will not work from within Kodi! It works fine over SSL or command line. I even put a test output line and tried spitting the output from the command (in the .sh) to a file. The test output line is there, but not the result of the execution! Its like the script just ends.

The code I am using for HDMI is “vcgencmd display_power 0” for off (and 1 for on).

I looked briefly at the kodi.log and its saying the script executed as expected:
01:21:06 102.716949 T:1957487152 DEBUG: Keyboard: scancode: 0x57, sym: 0x0124, unicode: 0x0000, modifier: 0x1000
01:21:06 102.717270 T:1957487152 DEBUG: OnKey: f11 (0xf09a) pressed, action is XBMC.RunScript(/home/osmc/
01:21:06 102.717888 T:1639334944 NOTICE: Thread LanguageInvoker start, auto delete: false
01:21:06 102.718109 T:1639334944 INFO: initializing python engine.
01:21:06 102.718208 T:1639334944 DEBUG: CPythonInvoker(4, /home/osmc/ start processing
01:21:07 103.117165 T:1639334944 NOTICE: -->Python Interpreter Initialized<–
01:21:07 103.117500 T:1639334944 DEBUG: CPythonInvoker(4, /home/osmc/ the source file to load is “/home/osmc/”
01:21:07 103.117599 T:1639334944 WARNING: CPythonInvoker(4): Script invoked without an addon. Adding all addon modules installed to python path as fallback. Thi$
01:21:07 103.120537 T:1639334944 DEBUG: CPythonInvoker(4, /home/osmc/ setting the Python path to /home/osmc:/usr/share/kodi/addons/script.module.x$
01:21:07 103.120796 T:1639334944 DEBUG: CPythonInvoker(4, /home/osmc/ entering source directory /home/osmc
01:21:07 103.332787 T:1639334944 INFO: CPythonInvoker(4, /home/osmc/ script successfully run
01:21:07 103.341873 T:1639334944 INFO: Python script stopped
01:21:07 103.342163 T:1639334944 DEBUG: Thread LanguageInvoker 1639334944 terminating

Any Ideas???

How did you call vcgencmd in your script? Full path?
Maybe post your script for review.

1 Like

import sys
import subprocess["/home/osmc/"])

echo "first sh" >> /home/osmc/hdmioff.txt
vcgencmd display_power 0 >> /home/osmc/hdmioff.txt

Of course most of the code there is for testing.

For the keymap file:

<d>Notification(Keypress, You pressed D!, 3)</d>

I’m 99% sure that the keymap is not the issue as I have posted notifications with the F11 key and the runs fine.

Anyone else able to test this out?

That was it!!! I needed to use /opt/vc/bin/vcgencmd display_power 1 for that line.

Thanks heaps for that!!!

Seems System.Exec does work and there is no need for the .py as well :slightly_smiling:

Yep that is what I thought, you don’t have path environment in the script.

1 Like