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

Python • Re: PulseAudio and Root User Headaches

$
0
0
.sh script itself:

ps -e | grep pulse
pidof pulseaudio

cd /
cd home/cam/shared/ST2/
python3 st_ws.py
cd /

There is nothing in that script to start pulse audio or to delay starting your script until PA is ready. All it does is print any entries from the process list that contain "pulse" and the process ID of any process called "pulseaudio" which will then be discarded by cron. Which won't matter anyway as nothing will be found (unless you have manually configured your Bookworm OS to use Pule Audio instead of the default PipeWire).

As for the three cd commands, two of them are completely unnecessary and the other is only required if your python script accesses files that are in the same directory it is by relative path. If you want to keep the second cd command change home to /home

The thing that fixed audio is almost certainly the switch from root to cam.

Assuming your python script doesn't need a cwd* of /home/cam/shared/ST2/ you can replace the entire script with the following in your user's crontab:

Code:

@reboot python3 /home/cam/shared/ST2/st_ws.py
If it does need to run from that directory:

Code:

@reboot cd /home/cam/shared/ST2 && python3 st_ws.py
*: current working directory

Statistics: Posted by thagrol — Sun Dec 08, 2024 2:22 pm



Viewing all articles
Browse latest Browse all 4825

Trending Articles