RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    GPIO button to launch Kodi from EmulationStation?

    Scheduled Pinned Locked Moved Help and Support
    gpioscriptpython
    3 Posts 2 Posters 318 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • megapitchM
      megapitch
      last edited by

      I use Kodi often, and I control it with my phone. I don't always have a keyboard or gamepad handy to launch Kodi, though, so I would like to setup a GPIO button to launch Kodi from within EmulationStation.

      I've modified my case to include a button. Currently it's used as an ON/OFF switch, but I'd eventually like to have it launch Kodi when the button is long-pressed. I've written a script to test this, but the trouble is I can't get it to launch Kodi when EmulationStation is running. If I run it from the commandline or desktop, it works fine. Is there a specific method to run Kodi that plays nice with EmulationStation? Something about runcommand, maybe? I'm a little out of my depth here..

      Here is the basic version of my script:

      import gpiozero 
      import subprocess
      
      def callback(*args):    
          subprocess.call(["kodi"])
      
      if __name__ == '__main__':
          btn = gpiozero.Button(3)
          btn.when_released = callback
          while True:
              pass
      

      Currently it runs at boot from /etc/rc.local like so:

      sudo -u pi python3 /home/pi/kodi.py &
      

      Not sure what else to include, but happy to provide any additional info.

      1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator
        last edited by

        Try creating a script that shuts down gracefully EmulationStation before launching Kodi and call that script in your GPIO input handler.

        1 Reply Last reply Reply Quote 1
        • megapitchM
          megapitch
          last edited by

          Thanks. As soon as I posted here, I found this topic and with a bit of modification I was able to get it working. :)

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

          Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.