3

I have edited the autostart in "/etc/xdg/lxsession/LXDE-pi/" to this:

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
point-rpi
@lxterminal -e /home/pi/myScript.sh

All the script does is run an executable:

#!/bin/bash
/home/pi/myProgram

When the Pi is hooked up to a monitor, autostart works fine. Terminal pops up and the script is run with no issues. However, when I unplug the monitor and start the Pi, autostart doesn't run my script. I can still ssh into the pi and run it, but that's not a good solution for my situation.

Is there something in autostart that requires a monitor hookup?

DreamCloud
  • 31
  • 1
  • 2
    perhaps adding hdmi_force_hotplug=1 will make the pi boot up as if a monitor is present – Jaromanda X Jul 15 '20 at 04:00
  • @JaromandaX Thank you! Just tried this and everything seems to be working just fine now. I'd still be interested in learning about why this works and how monitors affect autostart. – DreamCloud Jul 15 '20 at 04:20

2 Answers2

2

You are using the autostart feature of the desktop environment, which cannot run without a screen. HDMI is smart enough to tell whether a screen is connected to it, and hdmi_force_hotplug dumbs it down exactly for cases like yours.

If your script doesn't actually need a desktop environment (it's not starting any graphical apps or changes the desktop resolution for instance), you should consider using systemd to start it up instead of LXDE.

Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144
1

You are mistaken; the Pi should boot, but if there is no monitor there will be no desktop so the GUI will not start. This affects the Pi4, earlier models would start, but use the composite video as output.

There is an option hdmi_force_hotplug=1 in config.txt and you should set a default resolution. See https://raspberrypi.stackexchange.com/a/113873/8697

Milliways
  • 59,890
  • 31
  • 101
  • 209