[SOLVED] Time dependent startup into either ES or Desktop
-
The short of it is that depending on the time of day I would like my Pi to either boot directly to the Desktop or to EmmulationStation Is this possible and if so what script(s) needs to be edited with the appropriate logic (I'm good with the if logic itself just, apparently, not where to best insert it)?
Pi Model or other hardware: 3B+
Power Supply used: Cannakit PS that shipped with the kit
RetroPie Version Used :4.4.14
Built From: SD Image on RetroPie
USB Devices connected: PS3 Controller
Controller used: PS3 Controller
Error messages received: N/ALong version is that I want my Cabinet to run PiClock Weather display during the morning hours as we get ready for the day and any time it's booted outside of the specified times it should go right into ES.
I have used the setup script to install the Desktop environment and have the system to boot into ES. Within ES there is a "Ports" section which has one "rom" of "Desktop" (which runs Desktop.sh).
I have also installed https://github.com/n0bel/PiClock the PiClock software, configured it to launch at desktop startup.
Manually launching the "Desktop" from within the Ports section of EmulationStation works beautifully.
Step 1: from here I'm trying to find a way, presumably, via autostart.sh to launch the desktop with a command line command.
Once that is working
Step 2: would be to be to add the if statment logic to check the time and if between hours of X and Y then launch Desktop otherwise ESmy current autostart.sh script is as follows:
(sleep 1; mpg123 -Z /home/pi/RetroPie/roms/music/*.mp3 >/dev/null 2>&1) & emulationstation --no-splash #auto
I have tried altering the emulationstation call to
/opt/retropie/supplementary/runcommand/runcommand.sh 0 _PORT_ "lxde" "" && emulationstation --no-splash #auto
Based on this thread: https://retropie.org.uk/forum/topic/10118/retropie-boot-into-a-single-rom/10
The bit leff of the "&&" was taken from the Retropie generated "Desktop.sh" which lives at /home/pi/Retropie/roms/ports/
When the system boots I do see the runcommand.sh window (same as when I "select" Desktop manually from within ES) but after a few seconds it dumps me into ES.
Edit: I also tried this which I think is more in line with the aforementioned reference topic solution:
/opt/retropie/supplementary/runcommand/runcommand.sh 0 \_PORTS\_ lxde ~/RetroPie/rom/ports/Desktop.sh && emulationstation --no-splash #auto
/dev/shm/runcommand.log file:
cat: /home/pi/.attract/romlists/.txt: No such file or directory ls: cannot access '/home/pi/RetroPie/videoloadingscreens/.mp4': No such file or directory ls: cannot access '/home/pi/RetroPie/videoloadingscreens/lxde.mp4': No such file or directory Parameters: Executing: startx X.Org X Server 1.19.2 Release Date: 2017-03-02 X Protocol Version 11, Revision 0 Build Operating System: Linux 4.9.41-v7+ armv7l Raspbian Current Operating System: Linux retropie 4.14.30-v7+ #1102 SMP Mon Mar 26 16:45:49 BST 2018 armv7l Kernel command line: 8250.nr_uarts=0 bcm2708_fb.fbwidth=1824 bcm2708_fb.fbheight=984 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 dwc_otg.lpm_enable=0 console=ttyS0,115200 console=tty3 root=PARTUUID=f2d3cb4f-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait loglevel=3 consoleblank=0 plymouth.enable=0 usbhid.quirks=0x16c0:0x05e1:0x040 logo.nologo vt.global_cursor_default=0 Build Date: 18 October 2017 04:55:30PM xorg-server 2:1.19.2-1+rpt1+deb9u2 (https://www.debian.org/support) Current version of pixman: 0.34.0 Before reporting problems, check http://wiki.x.org to make sure that you have the latest version. Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: "/home/pi/.local/share/xorg/Xorg.0.log", Time: Sat Jun 8 17:55:03 2019 (==) Using system config directory "/usr/share/X11/xorg.conf.d" (EE) Fatal server error: (EE) parse_vt_settings: Cannot open /dev/tty0 (Permission denied) (EE) (EE) Please consult the The X.Org Foundation support at http://wiki.x.org for help. (EE) Please also check the log file at "/home/pi/.local/share/xorg/Xorg.0.log" for additional information. (EE) (EE) Server terminated with error (1). Closing log file.
so looks like there is some problem starting the X server or accessing it.
-
@dupreesdiamond said in Time dependent startup into either ES or Desktop:
When the system boots I do see the runcommand.sh window (same as when I "select" Desktop manually from within ES) but after a few seconds it dumps me into ES.
Yes, it happens so why you commanded to do so.
Your code logic should look more like
if (between hour x or hour y); then start lxde else start emulationstation fi
-
Maybe I don't understand where that should go. But if I put "start lxde" into the autostart.sh script it just dumps me to the command line stating that "start" command is unkown/invalid.
And based on what I observe when using the retropie-setup to swap between booting to Desktop vs Emulationstation (it symlinks different files into /etc/systemd/system/default.target ) according to the text that pops up bottom left of screen after selecting "ok"
I'm not sure it's that simple. At least not as simple as adding those lines to autostart.sh maybe I should be putting those lines in some other script?
-
After the aforementioned attempt failed. and it was sitting on the terminal I typed "startx" at the prompt and that took me into the desktop. Exciting. So I
tried an autostart.sh with a single line:
startx
And it looked like it might work but it just hangs out on a blank screen unfortunately. Can't even SSH in as it's hung...
-
@dupreesdiamond I never started a desktop variant. But
startx
is the correct command as far as I remember. But the usage ofstartx && emulationstation
is wrong. You need an if clause to determine which system to start. -
Right I never had a command startx && emulation station.
the change I made was a single line
startx
to see if, from autostart.sh , I can even get into the desktop.
The aforementioned attempt only managed to hang the system on boot.
The only time I was using && emulationstation was, as noted, in the same way folks use that command to launch a single rom on ES opening. The idea was to launch the Desktop through ES same as one would launch a rom.
From what I can tell I need to either inject the "IF" logic at an earlier point in the boot process (if so I'm way out of my depth) or figure out how to make Emulationstation launch the "ports/Desktop.sh" "rom"
-
@dupreesdiamond
https://retropie.org.uk/forum/topic/12713
Maybe this could help... -
Thanks.
Hmm That looks like booting to the desktop then user actions to move from X to ES and vice versa but I'll look into it for sure as there might be something in there I can leverage.
I guess ultimately I could boot to the CommandLine (Or desktop) then run the script to launch the clock/weather or ES but that doesn't seem that it would be as elegant/efficient for booting into ES outside of the morning hours as, ideally, outside of 7-8am for example it should just cleanly boot right into ES. The above would be not all that different but is still not the same.
-
Resolved it by configuring retropie to boot to the command line and then i'll edit .bashrc to house the if logic to launch X or ES depending on TOD and of course
if [ "`tty`" = "/dev/tty1" ]
Was much easier than I was trying to make it...
##### # Set the hours between which PiClock will Launch #### minHour=6 maxHour=9 #Get Current Hour cHour=$(date +%H) # Get current time and time of boot. # calculate minutes since boot cSec=$(date +%s) sSec=$(date +%s -d "$(uptime -s)") uMin=$(( ($cSec - $sSec)/60 )) # Ensure that we are within 2 minutes of boot. This ensures that user can exit ES to the command line # without this script re-launching ES in an endless loop if [[ $uMin -le 2 ]]; then # Ensure this is tty1 if [[ "`tty`" = "/dev/tty1" ]]; then # If between min and max hour then startx and PiClock else execute autorun if [[ $cHour -ge $minHour && $cHour -lt $maxHour ]]; then startx else bash "/opt/retropie/configs/all/autorun.sh" fi fi fi
The issue I see is trying to drop to the command line from ES in which case I believe it will just launch back into ES... i'm ok with this.Maybe some other unintended consequences but I'll find out soon enough.Edit: Added an additional If statement to check for minutes since boot so that one can successfully drop from ES to the CL without
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.