METADATA not saving - Favorites will never remain tagged
-
@semper-5 The best way would be to edit with SSH connection and nano.
use putty, don't use WINSCP
cd /home/pi/RetroPie/scripts
1.1 if directory scripts does not exists usemkdir /home/pi/RetroPie/scripts
1.2 then try again withcd /home/pi/RetroPie/scripts
rm switch.sh
this will remove scriptnano switch.sh
copy text from code box below
3.1 After inserting code with left mouse button
3.2 Press CTRL+X and press Y to save scriptchmod +x switch.sh
makes script executablesudo ./switch.sh &
to start script in background with root privileges ;)
switch.sh CODEBOX
#!/bin/bash # End Emulationstation if condition of running binary is true (v1.599) # v1.0 07/21/17 by cyperghost - Inital run # v1.5 07/27/17 - Great step to exit ES even if emulators is running by runcommand.sh are started // meleu # v1.56 07/30/17 - All emulators will be detected. // meleu # v1.58 08/02/17 - generel method: Use PPID to detect child PIDs now (ScummVM fix) // cyperghost # v1.595 11/14/17 - Inserted newest emucall detection // meleu # v1.599 04/18/18 - NESPI case # v1.6 04/20/18 - added kill -9 to terminate emulators // julenvitoria # greetings @pjft for his famous favorits and @meleu for his RegEx sniplets and his constant help! #this is the GPIO pin connected to POWER SWITCH GPIOpin1=24 #this is the GPIO pin connected to POWER ON CONTROL GPIOpin2=25 echo "$GPIOpin1" > /sys/class/gpio/export echo "in" > /sys/class/gpio/gpio$GPIOpin1/direction echo "$GPIOpin2" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio$GPIOpin2/direction echo "1" > /sys/class/gpio/gpio$GPIOpin2/value power=$(cat /sys/class/gpio/gpio$GPIOpin1/value) [[ $power == 0 ]] && switchtype="1" #Not a momentary button [[ $power == 1 ]] && switchtype="0" #Momentary button until [[ $power == $switchtype ]]; do power=$(cat /sys/class/gpio/gpio$GPIOpin1/value) sleep 1 done # Detect PID or EMULATOR NAMES emucall="$(sed '4!d; s/\([\\"]\|[[:alnum:]_]\+=[^ ]* \)//g; s/[][(){}^$*.|+? ]/\\&/g' /dev/shm/runcommand.info)" espid="$(pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)")" echo "Button Pressed: $power - Switchtype: $switchtype" echo "ES-PID: $espid" sleep 5 # Handle calls and send TERM signal if [[ -n "$emucall" ]]; then emupid="$(pgrep -f "$emucall" | tr '\n' ' ')" pkill -P "$(echo $emupid | tr ' ' ',')" kill -9 "$emupid" sleep 4 fi if [[ -n "$espid" ]]; then touch /tmp/es-shutdown && chown pi:pi /tmp/es-shutdown kill "$espid" exit fi echo "Script terminated not by ES!"
-
@semper-5 It's very strange... for example lines 10, 13, 16, 22 and 26 are blank... It works for me but not in the totality of the emulators.
@cyperghost As I mentioned it really works for me, but not in the totality of the emulators... For example it works with retroarch and advancemame but doesn't work with pifba, pcsx-rearmed or mame4all. If I try the commands separately pgrep -f doesn't detect this emulators... pgrep -f "$emucall" doesn't show any pid. Any suggestion for detect the emulators properly?
Thanks
-
@julenvitoria Thanks for the headup. As I wrote this is just a basic script! meleu is the RegEx wizard out here. I changed codebox.... please try again.
I addedemupid="$(pgrep -f "$emucall" | tr '\n' ' ')" pkill -P "$(echo $emupid | tr ' ' ',')"
PS: That are the outfindings of @meleuI'm working on annother emulator detection - Shutdown script some input for better emulator detection
The errors @Semper-5 descripes are caused because these "empty" lines contain Carriage Return (CR) character (0x0D, \r) ... Windows uses linefeed (LF) and carrige return (CR) for creating a new line.
-
@cyperghost said in METADATA not saving - Favorites will never remain tagged:
emupid="$(pgrep -f "$emucall" | tr '\n' ' ')" pkill -P "$(echo $emupid | tr ' ' ',')"
Hi! I tried your new code but don't work with pifba nor mame4 all. However it worked with pcsx-rearmed emulator. I tried kill -9 "$emupid" and then it works. I dont know if it is advisable or not to do this. If you know any other way I would appreciate it.
Thanks!
-
@julenvitoria said in METADATA not saving - Favorites will never remain tagged:
@cyperghost said in METADATA not saving - Favorites will never remain tagged:
emupid="$(pgrep -f "$emucall" | tr '\n' ' ')" pkill -P "$(echo $emupid | tr ' ' ',')"
Hi! I tried your new code but don't work with pifba nor mame4 all. However it worked with pcsx-rearmed emulator. I tried kill -9 "$emupid" and then it works. I dont know if it is advisable or not to do this. If you know any other way I would appreciate it.
Thanks!
Really don't know why this is happening. I just copied some text parts.
But you may test this script here, please?
All you have to do is to copy from textbox into a bashfile. Maybeemu_shutdown.sh
, make it executable withchmod +x emu_shutdown.sh
and execute it via SSH if an emulator is running?Maybe you will get better results then? It will only terminate emulators, not more not less.
-
@cyperghost Hi, I tried your emulator detector too and the result was the same more or less. There were some emulators that dont stop... If you prefer I could write you throug the other thread.
-
@julenvitoria Thanks! You are right the signal levels are ignored by some emulators.
I would suggest to usekill -9 <PID>
I will update both scripts. So you see - once again something new explored .... ;)
-
Ok, so no errors to report. But the power switch doesn't work now.
I temporarily took out the entry in autostart.sh just to see what would happen in putty. and like I said, no errors. but when i press the power button (off) it does nothing -
@cyperghost wow! It’s perfect!! I’ll try the other script later
Thanks!
-
@semper-5 Please do so as you wrote. Take auto entry from autostart.sh!
and do a manuel start via SSH to see error messages. I need the routine how the POLOLU acts with the switch.Please use
sudo /path/to/switch.sh &
command with the latest script version.@julenvitoria You are welcome! Thank you for testing. The other script is also working! I tested several times.
-
@cyperghost it doesn't output any errors.
I enter:
sudo bash /home/pi/RetroPie/scripts/switch.sh &
output: [1] 10921I think it s working to some extent because if I try to run it again it will tell line 18 & 20 write protection due to device being busy
-
@semper-5 That's okay ... this [10921] thing is the process number.
So what happens if you press the power button? With the script in background running?You should see a message like:
Switch press 0 - Switchtype 1
ES-PID: 1232 -
@cyperghost no message, no activity, no error. nothing :/
-
@semper-5 What is the output of
cat /sys/class/gpio/gpio24/value
if the power button is pressed, and then if the power button is released?
It should be 1 if pressed and 0 if releasedThe script must be active for this ;)
-
@cyperghost it's 0 on both being pressed and released
-
-
@cyperghost I know! Our frustration is real. I mean it works as it should with Yahmez's script. And just to be sure I am following your instructions immaculately, yours is the ONLY script I'm running on this fresh image.
Geez it was embarrassing you guys telling me to use Notepad++ and how to invoke the script LOL. but I do appreciate all your efforts to walk me through it. I'm just thinking you guys must be getting as frustrated with me as I'm getting frustrated with this not working - I'm yelling at this damn box like "you're making an idiot out of me in front of the community, damn you!" haha
-
@cyperghost
I am late to the game here but if my script works as intended (minus saving metadata which was never implemented) and cypherghost's script is not seeing the button presses then the logical thing would be to compare the two scripts and see how they are being handled differently. -
@yahmez ;)
Thank you for stepping in my friend.
So let's compare ;)#!/usr/bin/python import RPi.GPIO as GPIO import os, time GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Reset switch GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP) #Power switch GPIO.setup(25, GPIO.OUT) #ON control GPIO.output(25, GPIO.HIGH) while True: if (GPIO.input(24)): time.sleep(0.25) else: print ("Shutting down...") os.system("sudo shutdown -h now") break if (GPIO.input(23)): time.sleep(0.25) else: print ("Resetting...") os.system("sudo reboot now") break
and
script version from here
I did not implent reset handling here ;) -
@cyperghost Maybe the wires are connected to other pins ?
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.