Script to start ES or Desktop on boot
-
You can apply the same switching logic (from
/etc/rc.local
) in the autostart script from/opt/retropie/configs/all/autostart.sh
. The script is responsible for auto-starting EmulationStation and runs as thepi
user. You can check which display is connected and start either EmulationStation orstartx
. -
@mitu said in Script to start ES or Desktop on boot:
/opt/retropie/configs/all/autostart.sh
Well.....
The only thing in the file right now is
emulationstation #auto
But I already found a post from 2016 (if not mistaken) with no resolution where the OP tried that and it would just black screen. He said if you get to the autostart file, it was too late on his tests.
I will try it later anyway and let you know, thanks o/
-
@mitu
Yep, black screen.I'm trying this code, see any errors?
#if HDMI connected, go to desktop video="$(tvservice -s | sed "s/^.*\[\([^ ]*\) .*$/\1/" )" if [ "$video" == "HDMI" ]; then startx else emulationstation #auto fi
-
If I save the script you posted and execute it with
bash <scriptname>
, I get an errorsed: -e expression #1, char 23: Unmatched ) or \)
If you execute the script manually, after boot, does it determine correctly if it should start ES or the Desktop ?
-
@mitu it works as intended in rc.local to load the lcd driver when no HDMI is detected.
Unless it is miss understanding the commas, I'm not finding any mismatch.Maybe if I set both ES and Raspbian to load to prompt and decide with to start in rc.local, hum....seams a good idea.
I will test later, thanks o/
-
@Frazatto said in Script to start ES or Desktop on boot:
@mitu it works as intended in rc.local to load the lcd driver when no HDMI is detected.
Are you running this from
rc.local
or fromautostart.sh
?Unless it is miss understanding the commas, I'm not finding any mismatch.
I'm just posting what I get when running the script.
-
@mitu said in Script to start ES or Desktop on boot:
Are you running this from
rc.local
or fromautostart.sh
?I already have a similar code running in rc.local to switch between lcd or hdmi on the fly and it has been working as intended.
Now I'm trying to choose ES or Desktop depending if HDMI cable is connected or not.My previous idea won't work.....rc.local is not the last script to run during boot and trying to bring up a GUI before end of boot is probably a bad idea.....hum.....
One thing I noticed, autostart.sh doesn't have the #!/bin/bash header, is it really a bash script??? Or is it just a flag for what ever ES is doing to start after boot?
-
@Frazatto said in Script to start ES or Desktop on boot:
One thing I noticed, autostart.sh doesn't have the #!/bin/bash header, is it really a bash script??? Or is it just a flag for what ever ES is doing to start after boot?
It's a Bash script. This is how EmulationStation is started automatically on boot.
-
@mitu Okkk....I researched a little more and tried this script:
#if HDMI connected, go to desktop video="$(tvservice -s)" if [[ $video =~ "HDMI" ]]; then startx else emulationstation #auto fi
And I tested just with strings and bash before truing to boot and I'm 100% sure it does what I expect.
But black screen is confirmed if you try to startx inside autostart.sh!!!!!I will have to find another way of doing this.
-
@Frazatto do you have splash screen enabled? Try disabling
-
@BuZz all splash screens are disabled.
-
Some more info...
Adding & after startx let the terminal keep running and showed me the real errors occurring.
You will get an permission denied as tty1 is occupied by the original user, Xorg can't start since the display is already in use and I don't want to run Desktop as root all the time and adding Pi to tty group only cascade into other access errors.So I think this is a definitive answer that it is not possible to startx conveniently on ES autostart.sh
-
@Frazatto said in Script to start ES or Desktop on boot:
So I think this is a definitive answer that it is not possible to startx conveniently on ES autostart.sh
No, it's not - I actually tested and it works. I'm on the latest RetroPie version (Raspbian Buster) and I have no problem starting the desktop from
autostart.sh
.Maybe you should give more details about your system, as detailed in https://retropie.org.uk/forum/topic/3/read-this-first.
-
That is unexpected.......
Yes I did read that, didn't seam pertinent till now.raspberry pi 3B+
Raspbian Buster
Retropie 4.6.2 -
Try this - disable any programs in
autostart.sh
. On boot, you should be presented with a command line prompt. Runstartx
from there and see if it works. If it doesn't, post the X.org log file to pastebin.com, from$HOME/.local/share/xorg/
. -
@mitu now I'm just confused :D
If I try what you asked, it works just fine.
So I went ahead and tried juststartx &
in autostart.sh and I get the same error.
This is the log you asked for when the desktop fails to start:
(the line about xf86OpenConsole used to be an access error to tty1 that I "fixed")[ 20.335] X.Org X Server 1.20.4 X Protocol Version 11, Revision 0 [ 20.342] Build Operating System: Linux 4.15.0-48-generic armv8l Raspbian [ 20.345] Current Operating System: Linux BMO.local 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020 armv7l [ 20.345] Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 snd_bcm2835.enable_headphones=1 bcm2708_fb.fbwidth=1280 bcm2708_fb.fbheight=720 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 dwc_otg.lpm_enable=0 console=tty1 console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo [ 20.356] Build Date: 05 June 2019 12:49:54PM [ 20.359] xorg-server 2:1.20.4-1+rpt1 (https://www.debian.org/support) [ 20.362] Current version of pixman: 0.36.0 [ 20.368] Before reporting problems, check http://wiki.x.org to make sure that you have the latest version. [ 20.368] Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. [ 20.380] (==) Log file: "/home/pi/.local/share/xorg/Xorg.0.log", Time: Sat Jul 4 15:48:27 2020 [ 20.394] (==) Using system config directory "/usr/share/X11/xorg.conf.d" [ 20.406] (==) No Layout section. Using the first Screen section. [ 20.406] (==) No screen section available. Using defaults. [ 20.406] (**) |-->Screen "Default Screen Section" (0) [ 20.406] (**) | |-->Monitor "<default monitor>" [ 20.425] (==) No device specified for screen "Default Screen Section". Using the first device section listed. [ 20.425] (**) | |-->Device "Allwinner A10/A13 FBDEV" [ 20.425] (==) No monitor specified for screen "Default Screen Section". Using a default monitor configuration. [ 20.425] (==) Automatically adding devices [ 20.425] (==) Automatically enabling devices [ 20.425] (==) Automatically adding GPU devices [ 20.426] (==) Max clients allowed: 256, resource mask: 0x1fffff [ 20.482] (WW) The directory "/usr/share/fonts/X11/cyrillic" does not exist. [ 20.482] Entry deleted from font path. [ 20.482] (WW) The directory "/usr/share/fonts/X11/100dpi/" does not exist. [ 20.482] Entry deleted from font path. [ 20.482] (WW) The directory "/usr/share/fonts/X11/75dpi/" does not exist. [ 20.482] Entry deleted from font path. [ 20.482] (WW) The directory "/usr/share/fonts/X11/Type1" does not exist. [ 20.482] Entry deleted from font path. [ 20.483] (WW) The directory "/usr/share/fonts/X11/100dpi" does not exist. [ 20.483] Entry deleted from font path. [ 20.483] (WW) The directory "/usr/share/fonts/X11/75dpi" does not exist. [ 20.483] Entry deleted from font path. [ 20.483] (==) FontPath set to: /usr/share/fonts/X11/misc, built-ins [ 20.483] (==) ModulePath set to "/usr/lib/xorg/modules" [ 20.483] (II) The server relies on udev to provide the list of input devices. If no devices become available, reconfigure udev or disable AutoAddDevices. [ 20.483] (II) Loader magic: 0x1fcf80 [ 20.483] (II) Module ABI versions: [ 20.483] X.Org ANSI C Emulation: 0.4 [ 20.483] X.Org Video Driver: 24.0 [ 20.483] X.Org XInput driver : 24.1 [ 20.483] X.Org Server Extension : 10.0 [ 20.487] (--) using VT number 2 [ 20.487] (II) systemd-logind: logind integration requires -keeptty and -keeptty was not provided, disabling logind integration [ 20.488] (II) no primary bus or device found [ 20.488] (II) LoadModule: "glx" [ 20.534] (II) Loading /usr/lib/xorg/modules/extensions/libglx.so [ 20.712] (II) Module glx: vendor="X.Org Foundation" [ 20.712] compiled for 1.20.4, module version = 1.0.0 [ 20.712] ABI class: X.Org Server Extension, version 10.0 [ 20.713] (II) LoadModule: "fbturbo" [ 20.713] (II) Loading /usr/lib/xorg/modules/drivers/fbturbo_drv.so [ 20.736] (II) Module fbturbo: vendor="X.Org Foundation" [ 20.736] compiled for 1.20.3, module version = 0.5.1 [ 20.736] Module class: X.Org Video Driver [ 20.736] ABI class: X.Org Video Driver, version 24.0 [ 20.737] (II) FBTURBO: driver for framebuffer: fbturbo [ 20.737] (EE) Fatal server error: [ 20.751] (EE) xf86OpenConsole: Cannot open virtual console 2 (Permission denied) [ 20.758] (EE) [ 20.764] (EE) Please consult the The X.Org Foundation support at http://wiki.x.org for help. [ 20.791] (EE) Please also check the log file at "/home/pi/.local/share/xorg/Xorg.0.log" for additional information. [ 20.799] (EE) [ 20.806] (WW) xf86CloseConsole: KDSETMODE failed: Bad file descriptor [ 20.806] (WW) xf86CloseConsole: VT_GETMODE failed: Bad file descriptor [ 20.806] (EE) Server terminated with error (1). Closing log file.
-
@Frazatto said in Script to start ES or Desktop on boot:
[ 20.751] (EE) xf86OpenConsole: Cannot open virtual console 2 (Permission denied)
The error shows you're trying to run X on the 2nd text console, not the first. When running on the 1st one, it should show something like
[420164.968] (++) using VT number 1
Do you have other configuration added to the default image ? Did you add something to
/boot/cmdline.txt
? -
@mitu manually? Never touched this file before.
This is it's content:dwc_otg.lpm_enable=0 console=tty1 console=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo
-
That's strange, doesn't look like a standard
cmdline.ext
. Did you install from a Raspbian Lite image or from a RetroPie image ? -
@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?
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.