Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

Run RetroPie from an icon on the Raspbian desktop / X



  • Hey everyone.

    Question to those that know more than I do about Emulation Station and/or Linux.

    I have RetroPie installed on an existing Raspbian install (thanks to the devs for finally making this possible!). In order to run it, I have to exit X, or switch to a different virtual console, and run the "emulationstation" command from there. If I don't, I receive "Error creating SDL Window".

    Ideally I want to be able to double click on an icon on my desktop which launches Emulation Station. When I quit Emulation Station, it goes back to the desktop as before.

    Does anyone know a way of doing this? I think a script might be able to do it but my knowledge of the Linux commandset is fairly limited. Something like the following:

    • chvt 2 (switch to virtual console 2)
    • Somehow automatically login
    • Have .bashrc run "emulationstation" for the user that was automatically logged in
    • When Emulation Station exits, run the "exit" command (placed after "emulationstation" in .bashrc)
    • Once we're back into the login prompt for virtual console 2, chvt 7 (switch to virtual console 7, which is the Raspbian desktop)

    Is what I'm hoping to do possible? If so, anyone have any advice on how to proceed?

    Thanks!



  • I think I've found a way. Posting here for anyone that might want to know how to do the same.

    First, create the new user and their home directory:

    • sudo useradd -m -d /home/thenewuser thenewuser

    Delete the password for the new account so there's no prompts:

    • sudo passwd -d thenewuser
      If after logging in it still requires one, try adding one with sudo passwd thenewuser and then running the remove command again

    Set the user's default shell to bash:

    • sudo chsh -s /bin/bash thenewuser

    Set the user's groups:

    • sudo usermod -a -G pi,adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,spi,i2c,gpio thenewuser
      NOTE: I used the same groups that the "pi" user is part of - Not doing this gives a "failed to open vchiq instance". No idea which groups are actually needed. Anyone that wants to do the work and figure out which are required is welcome to do so.

    Add the lines to launch and exit Emulation Station into .bashrc:

    • sudo nano /home/thenewuser/.bashrc
      Add to the end of the file:
      emulationstation
      exit
      Save the file

    Run using the following command (put this into a shell script and chmod it to +x if you'd like):

    • sudo agetty -a thenewuser --noclear tty2

    Hope that helps anyone coming here in future! :)



  • Look and see if you have a file /opt/retropie/configs/all/autostart.sh

    If you do, it may be the script which invokes "startx" which brings up the X window system for you. If yes, you could possibly modify this script to run in a loop which invokes startx and emulationstation, such that all you need to do is quit the application you are in and wait for the other to autostart. I haven't tried this myself but something like this may work:

    while true
    do
    startx
    emulationstation
    done



  • @tigerknee That seems an over complicated stuff to do. The problem with ES running at same time as X.org was because input devices losing controll. I don't know if that is still true. Does it work fine, while the desktop is still running, like playing games and return to the desktop?



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.