Stop and start Kodi with the remote control

  • I had a Raspberry that I used as a Mysql, web, ftp, samba, nfs, oscam,... server for my Nvidia Shield and other devices but, since I now have an S905X box, I decided to use it instead as a server for a far better experience. What I want is to stop and start Kodi with a key from my remote control, because is a waste of power having Kodi in the background when I don't use it, and I'd like to know how to do it without the need of SSH and a PC.

    Stopping is easy editing the keymap with the "Quit" function but, how could I send the "systemctl start kodi" command with the remote?

    Thanks in advance.

  • For those interested, it can be done with irexec:

    - Create the file /storage/.config/lircrc with the following:

    Code
        begin
            prog   = irexec
            button = KEY_FAVORITES
            config = Remote.sh
        end

    where button is the key you want to assign and config a script like this:

    Bash
    #!/bin/sh
    enabled=$(ps -ef | grep -v grep | grep kodi.bin | wc -l)
    
    if [[ $enabled == "0" ]]; then
        systemctl start kodi
    else
        systemctl stop kodi
    fi


    that starts kodi if isn't running and stops it if it is.

    Now you only have to add "irexec -d" to the autostart.sh file and reboot your box.