Hyperion button for on off

Hi, thnx for reading this im bumping in to a “problem”
On openelec i had this script, linked to my remote.xml SO when i pressed a button (blue) the rpi was checking if the hyperiond is loaded, if not it is loading it starts up, if it is loaded it stops. (on off switch).

in remote.xml (this is good)
RunScript("/home/osmc/hyperion/switch.py")

Now on OpenElec somebody wrote this script for me

    import subprocess

pid = subprocess.Popen('pidof hyperiond', shell=True, close_fds=True, stdout=subprocess.PIPE)

try:
    if pid.stdout.readlines():
        subprocess.Popen('killall hyperiond', shell=True)
    else:
        subprocess.Popen('/opt/hyperion/bin/hyperiond /etc/hyperion.config.json </dev/null >/dev/null 2>&1 &', shell=True)
except Exception, e:
    pass

But this doesnt do anything, anymore. I re-wrote the path in the script to the correcting once. i have this switch.py in /home/osmc/hyperion and hyperion app is on /opt/hyperion/bin/hyperiond

Can anyone help me with this?

got it fixed with installing killall

apt-get install psmisc

I know this is an old thread but thank you very much for this, was able to get it working with my OSMC setup but had to produce a shell script that runs the python script as sudo.

Maybe not the best solution but it works through remote.xml and a System.Exec command.

Thanks again