Friday, September 15, 2017

How to restart emulationstation on RetroPie over SSH

tl;dr: over ssh, run:
sudo systemctl restart autologin@tty1.service
You are probably looking for how to restart emulationstation on RetroPie, after running killall emulationstation in the first place. And you probably did everything over ssh so far.

After booting up, RetroPie starts emulationstation automatically using systemd autologin as the "pi" user, on the console terminal /dev/tty1. If you use a physical keyboard, you can switch to this console by pressing Alt-2, whereas the boot messages are in Alt-1.

The autologin actually starts a regular bash login shell, which runs /etc/profile, which bootstraps /etc/profile.d/10-retropie.sh. In that latter script, it checks the terminal is /dev/tty1, and only starts emulationstation if the terminal matches. If you quit emulation station from the console, it will drop back to the bash login shell, and if you exit from the bash shell, the autologin sequence starts over and runs emulationstation again. Note that the autologin sequence is not managed by systemd-logind, so it will not show when running the loginctl command.

Every time you login to ssh, the same /etc/profile.d/10-retropie.sh script runs, but since the terminal is not /dev/tty1, the script does nothing.

Now I wish to air some grievances. When googling how to do this (I figured someone must have figured this out before I did), I came across some misguided but well-intentioned answers (e.g. RetroPie forum, Reddit), but nothing is as egregious as this one in the Raspberry Pi forum. This poor chap asked a question, received some unhelpful responses from the moderator, and understandably became frustrated. Now this power-tripping moderator Jessie went all indignant, banned the user, locked the topic, and proclaimed "let other users take note here."

Even though I have nothing to do with that conversation, reading the thread made my blood boil. This Jessie character is exactly the repellant that Raspberry Pi needs to alienate more of its users. I am not impressed. I would not be surprised if there are other incidents of abuse by this moderator, and would recommend that he steps down if he had not done so already.