The preferred way to do this nowadays is via the systemd service. Begin by creating a unit file for this service…
sudo nano /lib/systemd/system/cube.service
(Substitute your editor of preference in place of nano if you like.)
Copy-and-paste the following into the new file, editing the “ExecStart” line to reference which of the programs you’d like to run. Can also change the directory name, if you’ve moved or called it something else:
[Unit] Description=Cube Service After=multi-user.target [Service] Type=idle ExecStart=/usr/bin/python /home/pi/Pi_Matrix_Cube/life.py -k 1 [Install] WantedBy=multi-user.target
When running programs in a service like this, it’s best to specify full, absolute pathnames for everything. In the example above, that includes python and the script name. If specifying images for the image viewer or globe programs, those should have a full path to the image files too.
Save this file and exit the editor.
A few commands then enable this new service and will launch it on startup:
sudo systemctl daemon-reload sudo systemctl enable cube.service sudo reboot
To change which program is loaded on startup, just edit /lib/systemd/system/cube.service and change the ExecStart line, and reboot. No need to repeat the systemctl commands.
Page last edited March 08, 2024
Text editor powered by tinymce.