MagicMirror² v2.5.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.

    AxLED


  • Module Developer

    Hi to all interested,

    i testet some hours and made little progress.

    There are following requirements:
    Tools:

    • pm2
    • xdotool

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

    • add a MagicMirror.sh file in the fork folder of retropie with the following code
    #!/bin/bash
        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/runcommand.sh, change links from tty to tty1. Make sure owner and group ist root after editing

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

    #!/bin/bash
    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

    Difficulties:
    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)

    AxLED



  • 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

    @Ramez
    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.

    AxLED