RetroPie EmulationStation: Games won't launch when started via systemd service - TTY/Terminal access required
-
Hey guys,
I'm encountering an issue with EmulationStation running through a systemd service on my Raspberry Pi 5. on bookworm. I understand this is not yet supported, but just thought maybe someone was doing the same thing and had a solution.
WHAT WORKS:
- EmulationStation launches and displays properly when started manually via SSH
- Games launch correctly when started manually
- Running runcommand.sh directly from terminal works fine
WHAT DOESN'T WORK:
- Games won't launch when EmulationStation is started via systemd service
- runcommand.sh seems to require TTY access which isn't available
TECHNICAL DETAILS:
- Running EmulationStation through a systemd service
- Environment variables are set correctly (DISPLAY, XAUTHORITY, XDG_RUNTIME_DIR)
- EmulationStation logs show it's starting properly
- When attempting to launch a game, runcommand.sh fails silently
I've confirmed this is a terminal/TTY access issue as the same setup works perfectly when run manually with TTY access. The core problem seems to be that runcommand.sh requires an interactive terminal, but when launched through a systemd service, this isn't available.
Has anyone encountered this before or found a way to launch games properly when EmulationStation is started via a service? Any suggestions for handling TTY access in this context would be appreciated.
- EmulationStation v2.11.2rp
-
I understand this is not yet supported, ...
I'd say that launching via
systemd
is also not a supported configuration, as you have already discovered. -
Has anyone encountered this before or found a way to launch games properly when EmulationStation is started via a service? Any suggestions for handling TTY access in this context would be appreciated.
I had the same issue. No systemd option...
My solution was to write a script to launch via Desktop's Autostart; open a terminal at full screen, force 720p (I need that to prevent crashing), and launch emulationstation.
-
@Arrafart said in RetroPie EmulationStation: Games won't launch when started via systemd service - TTY/Terminal access required:
My solution was to write a script to launch via Desktop's Autostart; open a terminal at full screen, force 720p (I need that to prevent crashing), and launch emulationstation.
Thanks for letting me know! Could you show your script and autostart desktop entry? I'm having similar issues and cant quite get it to run :)
Thanks
-
@liminal1 said in RetroPie EmulationStation: Games won't launch when started via systemd service - TTY/Terminal access required:
Thanks for letting me know! Could you show your script and autostart desktop entry? I'm having similar issues and cant quite get it to run :)
You can enable the auto-start of EmulationStation with your desktop session from RetroPie-Setup configuration section, under
autostart
. You can then enable auto-login in your login manager (gdm/sdm/etc.) to the deskop session, so that EmulationStation will start automatically at boot. -
@mitu Thanks mate!
I'm trying to use Desktop Entry, like the guy above Im trying to run emulation station from a script.
https://github.com/BYOBMO/BMOS
For this project.
This is what im running, but it just start and stops :(
[Desktop Entry] Type=Application Name=EmulationStation Comment=Launch EmulationStation in fullscreen terminal Exec=/home/pi/bmos/scripts/emulaunch.sh Terminal=false Categories=Game
#!/bin/bash # Log file setup LOG_FILE="/home/pi/logs/emulaunch.log" exec 1> >(tee -a "$LOG_FILE") exec 2>&1 echo "=== Starting EmulationStation launch script $(date) ===" # Set display resolution to 720p xrandr --output HDMI-1 --mode 1280x720 2>/dev/null || \ xrandr --output HDMI1 --mode 1280x720 2>/dev/null || \ echo "Failed to set resolution, continuing anyway..." # Ensure proper display environment export DISPLAY=:0 export XAUTHORITY="/home/pi/.Xauthority" # Change to ES directory cd /opt/retropie/supplementary/emulationstation/ || { echo "Failed to change to EmulationStation directory" exit 1 } # Launch ES with minimal options echo "Launching EmulationStation..." ./emulationstation --no-splash echo "=== Script completed $(date) ==="
-
@liminal1
Disclaimer: I've been using Linux for 2 months. Not a pro...You need to make it open a terminal at full screen before forcing emulationstation.
I'm sorry to say this, but I let AI create the script for me. I told it my device and OS, paths, HDMI output, terminal I use. Maybe gave permission, not sure. Opened the desktop application for Autostart and Voila...
- force resolution (if your system needs it)
- xdotool moves mouse in the corner ( otherwise I have it in the center within menus)
- open terminal full screen ( just check if you terminal needs toolbars etc. hidden)
- cd Emupath
- Launch emulationstation
I currently do not have access to the script for sharing, but it's very simple. I can share it later.
-
@liminal1 said in RetroPie EmulationStation: Games won't launch when started via systemd service - TTY/Terminal access required:
I'm trying to use Desktop Entry, like the guy above Im trying to run emulation station from a script.
I'm not familiar with the scripts from that repository - they might or might not work. Does it have any relation to RetroPie ? If you're using their scripts/programs, you may want to ask there for support, it doesn't seem like there's any relation with RetroPie.
This is what im running, but it just start and stops :(
There's too many commands just for starting EmulationStation. Is there an issue with the start-up script installed by RetroPie - any reason you're not using it ?These commands seem geared towards running EmulationStation from a desktop session, so if you haven't got a desktop session started they should fail. On the Pi we only support running from the terminal, by runningemulationstation
directly - that's all there is to it. -
@mitu Thanks for that, I understand. I think that other poster might have the special sauce that allows that. So ill just wait and see if they can shed some light. But thank you for taking the time to reply :)
-
@Arrafart Awesome thank you! If you can that would be great!
And don't worry, I'm using AI as well, don't be ashamed, its the great equaliser HAHA!!!
Thanks again :)
-
I boot into Dietpi OS desktop, Application Autostart launches the script after Desktop is booted.
Exiting back to Desktop is F4 (or shutdown with controller) followed by a ctrl+shift+w.
I hope you can use this principle for your needs :)
Good day! -
@Arrafart Thank you!
#!/bin/bash # Initial logging echo "Script started $(date)" > /home/pi/script_test.log echo "Running as: $(whoami)" >> /home/pi/script_test.log # Setup terminal and display export DISPLAY=:0 export XAUTHORITY=/home/pi/.Xauthority export XDG_RUNTIME_DIR=/run/user/1000 export TERM=linux # Create a pseudo TTY for RetroArch script -qc " cd /opt/retropie/supplementary/emulationstation/ ./emulationstation --no-splash --debug " /dev/null echo "EmulationStation exited at $(date)" >> /home/pi/script_test.log ~~~~ This is what ended up helping me in the end :)
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.