Skip to content

[Question] Check for running emulators or kodi #9483

@tonilsz

Description

@tonilsz

Hi,

I have a nespi+ case and I use safe shutdown and reset buttons from here:
https://github.com/edus44/lakka-gpio-control

It works perfectly, but I wanted a little update like here:
https://github.com/crcerror/retroflag-picase/blob/master/SafeShutdown.py

what I want is when reset button is pressed, check if we are running any emulator or kodi is open, for this we can inspire in this piece of code:

def reboot():
 output = int(subprocess.check_output(['/opt/RetroFlag/multi_switch.sh', '--es-pid']))
 output_rc = int(subprocess.check_output(['/opt/RetroFlag/multi_switch.sh', '--rc-pid']))
 if output_rc:
     os.system("/opt/RetroFlag/multi_switch.sh --closeemu")
 elif output:
     os.system("/opt/RetroFlag/multi_switch.sh --es-restart")
 else:
     os.system("sudo reboot")

I know that we don't have ES but I hope that check for some process can be possible

this is the code/pseudocode that I should develop:

def reset():
  oldState = True
  while True:
    GPIO.wait_for_edge(resetPin, GPIO.FALLING)

    state = GPIO.input(resetPin)
    if state != oldState and state == False:

      ## state_kodi =  funtionToCheckIfKodiIsRunning()
      ## state_cores =  funtionToCheckIfAnyCoreIsRunning()
      ## if state_kodi:
      ##         os.system("kodi-send --action="Quit"")
      ## elif state_cores:
      ##         FuntionLikeXMBCloseContent
      ## else:
      ##         os.system("pkill retroarch")
      ## time.sleep(1)

I hope that it isn't very confused, there is no problem if I have to develop a multi_switch.sh to handle better the events, but first I have to know if its possible and how to find references.

What I really need are two functions:

Can anyone show me the way or a doc page to find info related with this commands?

is it related to #4235

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions