TransWikia.com

Why does autostart only work when the Pi is hooked up to a monitor?

Raspberry Pi Asked by DreamCloud on October 5, 2021

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?

2 Answers

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

Answered by Milliways on October 5, 2021

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.

Answered by Dmitry Grigoryev on October 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP