Recalbox Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • recalbox.com
    • Gitlab repository
    • Documentation
    • Discord

    Nespi hack

    Recalbox General
    nespihack retroflag powereresetbut seguro
    1
    1
    740
    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.
    • rocordeiro
      rocordeiro last edited by

      Hello everyone I am new here in the forum and I have some doubts here, someone could help to solve this code below I picked it from the retropie used to turn off the system and respibarry in a safe way with a Power button. I've seen some topics but they usually use circuit boards different from the ones I have. see the script.

      mkdir -p /bin/button

      nano /bin/button/nespi.py

      #!/bin/python
      
      import RPi.GPIO as GPIO
      import os, time
      
      
      GPIO.setmode(GPIO.BCM)
      GPIO.setup( 2, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Reset switch
      GPIO.setup( 3, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Power switch
      GPIO.setup( 5, GPIO.OUT) #ON control
      GPIO.output( 5, GPIO.HIGH)
      
      while True :
      	if (GPIO.input( 3 )):
      		time.sleep( 0.25 )
      	else:
      		encho ( "Shutting down...")
      		os.system( "shutdown -h now")
      	break
      
      	if (GPIO.input( 2 )):
      		time.sleep( 0.25 )
      	else:
      		encho ( "Resetting...")
      		os.system( "reboot now")
      	break
      

      nano /etc/rc.local

      	python /bin/button/nespi.py &
      

      chmod u+x /etc/rc.local

      shutdown -h now

      #!/bin/bash
      
      # Check if EmulationStation is running. Finish the script if doesn't.
      	espid="$(pgrep -f "/opt/recalbox/supplementary/.*/emulationstation([^.]|$)")" || exit 0
      
      # the "sed" command below isn't a crypted message :), it's just a trick to
      # make $emucall regex-safe to use in the "pgrep -f" below.
      	emucall="$(sed '4!d; s/\([\\"]\|[[:alnum:]_]\+=[^ ]* \)//g; s/[][(){}^$*.|+? ]/\\&/g' /dev/shm/runcommand.info)"
      
      # If there's an emulator running, we need to kill it and go back to ES
      if [[ -n "$emucall" ]]; then
      		emupid="$(pgrep -f "$emucall" | tr '\n' ' ')"
      		pkill -P "$(echo $emupid | tr ' ' ',')"
      		kill "$emupid"
      		wait "$emupid"
      		sleep 5 # maybe it can be lesser
      fi
      
      kill "$espid"
      wait "$espid"
      sleep 5 # maybe it can be lesser
      

      /etc/killes.sh

      chmod a+x /etc/killes.sh

      /etc/systemd/system/killes.service

      [Unit]
      Description=Kill EmulationStation
      After=autologin@tty1.service

      [Service]
      Type=oneshot
      RemainAfterExit=true
      ExecStop=/etc/killes.sh

      [Install]
      WantedBy=multi-user.target

      systemctl enable killes

      thank you so much

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

      Want to support us ?

      100
      Online

      98.7k
      Users

      28.1k
      Topics

      187.0k
      Posts

      Copyright © 2021 recalbox.com