Friday, September 5, 2025

Autostarting a program with Raspberry Bookworm OS

For an index to all my stories click this text

October 2018 I wrote a story on how to build an internet radio with the Raspberry Pi Zero. You can find that story here: https://lucstechblog.blogspot.com/2018/10/raspberry-pi-internet-radio-part-3.html

As you might know (as a faithfull follower of this weblog) I am building a second version for using in my living room. The old one is still working in my mancave, and stays there.

The old one uses the, at that time, current Raspberry OS. And of course I am now going to use the latest version. And that posed a small problem.

The previous version (which still works flawlessly) modified the LXDE-pi file in a way that made the internet radio program start automatically when the Pi Zero booted. And that does not work anymore.

For those that are interested I'll show you how to make a Python program autostart with Raspberry Pi's Bookworm OS.

Modify .bashrc

There are several ways to make a program, any program, autostart but this is one of the easiest.

Open the console and type:

sudo nano /home/pi/.bashrc

This opens the .bashrc file in the Nano editor. Please not the . at the beginning of the .bashrc filename. This makes the file normally hidden.

This is a fairly large file. Scroll down to the end of the file, and at put down the next two lines:

echo Running at boot
python /home/pi/radio.py


Then press CTRL-O to save the file and CTRL-X to quit the Nano editor.

You can alter python /home/pi/radio.py in any program you want to start when the Pi boots.

Reset the Pi with:

Sudo reboot now

And the Pi will reboot and automatically runs your program.

That's all for now

Till next time
Have fun

Luc Volders