Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8051

Troubleshooting • Re: Autostart bashscript with libcamera does not work

$
0
0
Hello,

I have the following simple bash script named "camera.sh":

Code:

#!/bin/bashexport DISPLAY=:0.0export XAUTHORITY=~/.Xauthoritysleep 10libcamera-hello --fullscreen -t 0
When I add the following line to /etc/rc.local, the libcamera does not start:

Code:

sudo /home/pi/camera.shexit 0
The camera.sh file is executable and it works with the command line or double-clicking on it.
I'm using bullseye OS.

It appears from the above that your script or something it is calling needs the desktop. rc.local runs before the desktop has been started.

Additionally, "~/.Xautority" will be expanded to /root/.Xauthority as everything started in or by rc.local is run by root unless explictly configured to do otherwise.

sudo is also not needed in rc.local.

If you change your line in rc.local to the following you should get any error messages thrown in the .log file:

Code:

/home/pi/camera.sh >/home/pi/camera.log 2>&1
It work when logged in or double clicked because of difference in the execution environment between rc.local and a logged in terminal. For more details refer to the document I've linked to below.
What else can I try?
Running A Program At Start Up A Beginner's Guide

Statistics: Posted by thagrol — Thu Mar 07, 2024 2:32 pm



Viewing all articles
Browse latest Browse all 8051

Trending Articles