Kodi Community Forum
Need advice on how to execute a custom shutdown script - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: Linux (https://forum.kodi.tv/forumdisplay.php?fid=52)
+---- Thread: Need advice on how to execute a custom shutdown script (/showthread.php?tid=355854)



Need advice on how to execute a custom shutdown script - ozkhan1 - 2020-07-14

I am currently using CoreELEC in a dual boot with Android. I want to map a keyboard key to run a custom shutdown script which reboots the system from Android.
Now I know the commands that do that (Rebootfromnand && Reboot) but I am not sure how to bind it to a keyboard press (such as A FUNCTION KEY) 

I am using my system with a FLIRC device, so its easy for me to map a key to one of the function keys, I just dont know how to tell the box to execute that shutdown script once it receives the key press.

Can anybody help me with this? 

Thanks in advance!


RE: Need advice on how to execute a custom shutdown script - black_eagle - 2020-07-14

You need to create a keymap (wiki) with something like this in it.

xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<keymap>
    <global>
        <keyboard>
            <f11>RunScript(full/path/to/script/with/name.py)</f11>
        </keyboard>
    </global>
</keymap>

You will have to write a small python script to import os and call those shell commands as I don't think Kodi can natively call the shell.


RE: Need advice on how to execute a custom shutdown script - ozkhan1 - 2020-07-14

(2020-07-14, 14:17)black_eagle Wrote: You need to create a keymap (wiki) with something like this in it.

xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<keymap>
    <global>
        <keyboard>
            <f11>RunScript(full/path/to/script/with/name.py)</f11>
        </keyboard>
    </global>
</keymap>

You will have to write a small python script to import os and call those shell commands as I don't think Kodi can natively call the shell.

Cheers..

I got it to work. Thanks for your help!!