Script to start ES or Desktop on boot
-
@mitu
https://www.raspberrypi.org/downloads/raspberry-pi-os/
"Raspberry Pi OS (32-bit) with desktop and recommended software"
Than Retropie flowing the GIT guide.How does your look like?
What does this file do? -
@Frazatto Not sure if that file is the culprit, but I've seen configuration when the default tty was modified via that file. Sorry, I have no ideas why it's not working, I just tested on a stock RetroPie install and couldn't get any errors.
-
@mitu don't worry, you tried to the very end and I thank you!
On the Raspberry forum nobody even bothered to answer me :P -
@Frazatto said in Script to start ES or Desktop on boot:
On the Raspberry forum nobody even bothered to answer me :P
That's probably because your problem is specific to the RetroPie auto-start configuration and not something Raspbian/Raspberry Pi related.
-
Just for future reference, I was messing around with this problem again and it just worked now........
So to recap, if you want to change between X and EmulationStation depending on what output is connected, change
/opt/retropie/configs/all/autostart.sh
to something like the code below and it should work.#if HDMI connected, go to desktop
video="$(tvservice -s)"if [[ $video =~ "HDMI" ]];
then
startx
else
emulationstation #auto
fiI believe my Pi had some inconsistency in which user had ownership over the display, I manually set up ES and Rapibian to start on cmd, than in raspconfig set it to start X and lastly changed it back to ES to start by default. (yes, sounds complicated, but it was an accident really)
After that, the code snippet should work as intended.
-
Sorry to resurrect this interesting topic so much later. I came to it after looking for a script that allows us to select in a menu at the start if we want to start emulationstation or the desktop. I know that it's not exactly the same as what was discussed in this thread but it's very related. I've ended up making a custom script modifying
/opt/retropie/configs/all/autostart.sh
, and since I think it might be useful to someone, I'll leave it here for reference (this is the new content of thatautostart.sh
file):## Get WT Sizes WT_HEIGHT=18 WT_WIDTH=$(tput cols) if [ -z "$WT_WIDTH" ] || [ "$WT_WIDTH" -lt 60 ]; then WT_WIDTH=80 fi if [ "$WT_WIDTH" -gt 178 ]; then WT_WIDTH=120 fi WT_MENU_HEIGHT=$(($WT_HEIGHT-7)) ## Get Architecture ARCH=$(dpkg --print-architecture) ## Dialog Menu if [ "$ARCH" = "armhf" ] || [ "$ARCH" = "arm64" ] ; then sw=`DIALOG_ERROR=5 DIALOG_ESC=1 dialog --timeout 6 --no-cancel --title "Raspberry Pi Startup Selection Tool" --backtitle "$(cat /proc/device-tree/model)" \ --menu "Startup Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \ "1 EmulationStation" "Front-end of RetroPie Project" \ "2 Desktop" "Raspbian PIXEL Desktop Enviroment" \ "3 Console" "Abort auto-start and remain in console" \ 3>&1 1>&2 2>&3` else sw=`DIALOG_ERROR=5 DIALOG_ESC=1 dialog --timeout 6 --no-cancel --title "Raspberry Pi Startup Selection Tool" \ --menu "Startup Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \ "1 EmulationStation" "Front-end of RetroPie Project" \ "2 Desktop" "Raspbian PIXEL Desktop Enviroment" \ "3 Console" "Abort auto-start and remain in console" \ 3>&1 1>&2 2>&3` fi rc=$? #reset #no needed clear source $HOME/.bashrc case $rc in 0) case "$sw" in "1 EmulationStation") emulationstation ;; "2 Desktop") startx ;; "3 Console") echo "" ;; *) emulationstation ;; esac;; 1) emulationstation ;; 5) emulationstation ;; *) emulationstation ;; esac
This is what it looks like:
It's set to run emulationstation by default. A timeout of 6 seconds is established, so if the user does not press any key for 6 seconds, the default option (emulationstation) is executed. I've used
dialog
for the menu instead ofwhiptail
only because this last doesn't have the--timeout
option, and although you can achieve a similar effect with other tricks it's a bit more complicated, both should work fine either way.
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.