• 0 Votes
    15 Posts
    2k Views
    D

    I banged my head over this for some time before coming up with a solution.

    The problem is that when you hit that power button, an interrupt is sent to the login daemon, telling it to shutdown the system. You can't interrupt that in any way, or replace it with a different operation as far as I can see.

    You can create a service with killall -s SIGTERM retroarch in its shutdown operation - but by then it's too late. Systemctl has already killed all user processes - including retroarch.

    So what I had to do was actually run retroarch as a service itself. That was systemctl left it for its own shutdown procedure. I'm fairly new services, so I don't claim this is the perfect solution but it works for me.

    This is based on "retropie" on a Raspberry Pi. If you're running some other Linux system it may or may not be helpful.

    First, we need to prevent retroarch from starting in the normal way. I edited /opt/retropie/configs/all/autostart.sh, commenting out the existing lines and adding in a call to the shell bash:

    bash #/opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ mame-libretro ~/RetroPie/roms/mame-libretro/robotron.zip #emulationstation #auto

    Next I created a new service by adding a file /etc/systemd/system/killmame.service containing

    [Unit] Description=A service start and stop MAME cleanly After=console-setup network-online.target multi-user.target [Service] User=pi ExecStart=/home/pi/bin/start.sh ExecStop=/home/pi/bin/killmame.sh Type=simple StandardInput=tty-force TTYVHangup=yes TTYPath=/dev/tty20 TTYReset=yes SendSIGKILL=no KillMode=none [Install] WantedBy=multi-user.target

    Notes:

    You'll need to create that as root (eg. sudo nano killmame.service) killmame is a bad name for the service. It started off only intending to kill it, but morphed into a complete service - retroarch.service might be a better name All the tty stuff is needed or retroarch won't run The two scripts in ExecStart and ExecStop need to be created in the next step

    Now we create a directory /home/pi/bin and create the two scripts in the (can do this as the pi user):

    start.sh:

    #!/bin/bash cd /home/pi export TERM=linux export USER=pi chvt 20 /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ mame-libretro ~/RetroPie/roms/mame-libretro/robotron.zip & bash

    The command starting /opt/retropie is what I previously had in my autostart.sh. Obviously it's specific to my game, you will need to change it to whatever you had in your autostart.sh file.

    You MUST have the & character at the end, putting the command into background. Otherwise systemctl will kill it in the early steps of shutdown. I'm not sure why.

    killmame.sh:

    #!/bin/bash # echo checking for mame running ... > /home/pi/bin/killmame.log # ps -deafww | grep libretro | grep robotron >> /home/pi/bin/killmame.log killall -s SIGTERM retroarch echo shutting down MAME at `date` >> /home/pi/bin/killmame.log

    The commented-out lines 'echo' and 'ps' were for debugging - to see if my game was actually running when it came to being shut down.

    Finally we need to register and enable our new service:

    sudo systemctl daemon-reload sudo systemctl start killmame sudo systemctl enable killmame

    All those should complete without output. If the 'start' fails, you'll need to figure out why before continuing.

    If they all work, you can reboot. Your machine should first drop into a shell prompt, but then very soon after retroarch should take over. Hitting the kill switch should now shutdown retroarch cleanly, saving high scores.

    The only glitch I've found is that if you use <ESCAPE> to exit retroarch, you'll find lots of key presses on the shell window from your game controls. Usually they're harmless but it's just possible you might accidently issue some fatal commands. Probably removing the invocation of bash from autostart.sh woud solve that, but you might then not be able to get back into a shell after exiting with escape. I generally log in remotely using ssh, so that wouldn't worry me.

    I hope this helps someone as I spent hours trawling for a solution without finding one. It was only while explaining to my wife why it was impossible, that it occurred to me to actually run retroarch as a service itself.

    If someone is able to tidy this up into a cleaner solution I'd be very grateful.

  • What does this error mean? (lr-mess)

    9
    0 Votes
    9 Posts
    1k Views
    FollyF

    @JimmyFromTheBay said in What does this error mean? (lr-mess):

    If I can run them both at the same time that'd be great, but if not then it's not worth the hassle and risk.

    Technically it's possible but I think, for you, it's indeed not worth the hassle and the risk.

  • Run Redream PCSX2 and other stuff without having an x server

    6
    0 Votes
    6 Posts
    878 Views
    G

    Thanks for that advice, yeah I did install openbox, but not lightdm, I did already set up an autologon pre-x, so I just use xinit to start openbox, this works nice.

    Now I just need to configure some things in openbox, for instance runcommand and retropie-setup scripts run in a very small window in the center of the screen (I have a 4K screen), I guess I need to force fullscreen for everything, set larger font un xterm and/or set higher dpi at the openbox level.

    But Redream and PCSX2 run full screen so I'm almost done, I'll try to add more stuff like xemu, kodi and whatever I can now that there is an x server, this actually makes everything a lot easier... My mistake.

  • Issue with LCD Screen

    1
    0 Votes
    1 Posts
    266 Views
    No one has replied
  • Emulationstation -> black screen

    8
    0 Votes
    8 Posts
    682 Views
    R

    @mitu Thank you.
    Only option 1 was possible for me.
    My next step will be to buy a DualShock 4 gamepad.
    Also, I will try to install OpenMediaVault to have NAS.

  • Use emulator added independently

    2
    0 Votes
    2 Posts
    537 Views
    S

    @eje211 https://retropie.org.uk/docs/Add-a-New-System-in-EmulationStation/#step-31-launch-roms-with-the-runcommand-script

    You need to edit the launch command in your emulators.cfg at /opt/retropie/configs/gc/emulators.cfg and/or /opt/retropie/configs/wii/emulators.cfg. Replace the command (or add a new one) to use your installed binary instead of /opt/retropie/emulators/dolphin/bin/dolphin-emu

  • 0 Votes
    2 Posts
    436 Views
    WidgeW

    I found the answer, and it was the most obvious, of course.
    The SMS pause button is configured as the Port 1 Start button in retroarch, so whatever input I bin to Port1 Start does the job. Fortunately this still works if I have the input type as Light Phaser.

  • Emulationstation splash.svg how is it created?

    24
    0 Votes
    24 Posts
    4k Views
    W

    @fdr4prez

    Great thanks for the help, I'll get to it

  • This topic is deleted!

    0
    0 Votes
    0 Posts
    11 Views
    No one has replied
  • error ALSA lib seq_hw.c:466:(snd_seq_hw_open)

    1
    0 Votes
    1 Posts
    215 Views
    No one has replied
  • I cannot get the X68000 emulator to work.

    12
    0 Votes
    12 Posts
    4k Views
    mituM

    @cmdima You can usually find the BIOS information in the Docs. Also, please don't bump ancient topics, it's bad forum etiquette.

  • SDL2_ttf local build required.

    3
    0 Votes
    3 Posts
    287 Views
    mituM

    Spam post, it seems.

  • How to download kodi? Errors

    2
    0 Votes
    2 Posts
    551 Views
    mituM

    Some details about your setup would be helpful - https://retropie.org.uk/forum/topic/3/read-this-first.
    What's the exact error message you get when trying to install Kodi ?

  • Stopwatch for speed running?

    5
    0 Votes
    5 Posts
    679 Views
    AddisonA

    Yeah.

    It took me awhile just to find the leaderboards section for Super-Punchout.

    The site is a bit difficult for me to navigate through for some reason.

    Anyway, I tied in the top 7 earlier tonight for knocking out Gabby the quickest. :D

    The other times that were faster used the PAL version which is no longer supported, and to me, I considered that cheating. :P

  • 0 Votes
    12 Posts
    1k Views
    T

    @mitu

    BIG THANKS !!!!!

    1 > I updated retropie-setup script
    2 > I removed and reinstalled RUNCOMMAND
    3 > I tested different games and they worked ;-)

    Now I can play Zelda & 4 swords on Ubuntu 22.10 with Goverlay 9 !

  • retroarch msx cheats

    41
    0 Votes
    41 Posts
    11k Views
    W

    @barbudreadmon
    don't worry about that, thanks

  • Screen goes black every configuration submenu

    2
    0 Votes
    2 Posts
    305 Views
    E

    @Excalibas I fixed it commenting hdmi_safe 1 on config.txt

  • 0 Votes
    3 Posts
    670 Views
    T

    @mitu top man! <3

    all perfectly working :) thank you!

  • Emulationstation splash.svg

    9
    0 Votes
    9 Posts
    1k Views
    W

    @mitu
    ok I did it so as not to be repetitive

  • Rotate with a button...

    2
    0 Votes
    2 Posts
    339 Views
    T

    Hey there @ajlino ,

    I am in the same boat as you with this issue. I have a 2 player cocktail table built running Retropie on a Rasp Pi 3.

    I understand that not many roms support cocktail mode where the screen flips for P2, but I was hoping at least games like Pacman, DK, Galaga would work since the versions of roms I have appear to support this. But for the life of me I cannot get this screen flip to work at all on any game. I did manage to get Galaga to flip for P2 but it was all messed up and not playable.

    Did you ever have any success on getting this screen flip in 2p mode to work? It's frustrating seeing videos online of people getting this to work with no issue at all, and I am following the same exact method.

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.