MagicMirror² v2.13.0 is available! For more information about this release, check out this topic.

script or bash to exit MM and exit GUI and run a command in TTY mode

  • Module Developer

    Hi to all,

    i am trying to extend my MM for a second purpose -> Retropie.
    Therefore i need a script or bash or any way to do the following:

    • exit MM (maybe exiting PM2 is also fine)
    • exit the Raspian / Pixel GUI (as retropie dont run in GUI Mode)
    • run the “emulationstation” command in the TTY terminal

    Does anybody has hints for me to do that. For the beginning i would be also ok to run a script manual by entering the commands in terminal.

    Thanks in advance.


  • Module Developer

    Hi to all interested,

    i testet some hours and made little progress.

    There are following requirements:

    • pm2
    • xdotool

    Starting MagicMirror from Retropie works somehow, see the following lines:

    • add a file in the fork folder of retropie with the following code
        echo "starting MagicMirror"
        sudo service lightdm start #to start GUI
        #pm2 stop emulationstation, final commands missing so far
        pm2 start mm #to start MagicMirror
        xdotool key Ctrl+Alt+F7 #to change to tty7 = Gui
    • make this file executable

    Starting Retropie from MagicMirror works somehow, see the following lines:

    • editing file /opt/retropie/supplementary/runcommand/, change links from tty to tty1. Make sure owner and group ist root after editing

    • add a file in a folder of your choice with the following code

    echo 'starting Emulationstation/Retropie'
    sudo service lightdm stop #to quit GUI
    export DISPLAY=:0
    emulationstation > /dev/tty1 #to execute this command in tty1 where emulationstation/retropie runs
    • make this file executable
    • put this file into pm2

    I dont know how to put two .sh files into pm2 and set one to “start” and one to “stop”, if i only would have one of the to .sh files executed at one time (one .sh is for MagicMirror, second .sh is for emulationstation/retropie)


  • put the first one in /home/pi/retropie/roms/ports and you can run it under ports section in ES

    the closing script is a bit tricky you can use MM module that excute a terminal command to exit like this one MMM-TouchButtons and config it like that

      text: 'Exit MM',
      icon: 'skull',
      action: 'exec', 
      command: 'killall lightdm'

    it should kicks you back to ES

  • Module Developer

    Thanks for your reply, i want to have only one app (either mm or Retropie/Emulationstation) run at one time due the pi ressources.

    But i will try your approach.


Log in to reply