You probably don't want to be futzing with a keyboard and terminal to launch this project every time. Luckily you can configure it to run on boot by creating a systemd
unit file that runs the Python script within the Python venv after the desktop environment loads.
sudo nano /lib/systemd/system/nfcmovie.service
Copy and paste the contents of the text file below into the systemd file:
[Unit] Description=NFC Media Player After=x-session-manager.service [Service] User=USERNAME Environment=DISPLAY=:0 Environment=XAUTHORITY=/home/USERNAME/.Xauthority ExecStartPre=/bin/sleep 10 ExecStart=sudo /home/USERNAME/blinka/bin/python /home/USERNAME/nfc_movie_player.py [Install] WantedBy=default.target
Replace USERNAME with the username on your Raspberry Pi. The default is usually "pi".
The file waits for the desktop environment to load, waits another 10 seconds and then launches the Python script within the virtual environment.
Save the file. Then, in a terminal run these commands:
sudo systemctl enable nfcmovie sudo systemctl start nfcmovie
This enables the service and starts it. To test, reboot your Pi. After the desktop environment loads, you should see the script startup automatically.
Page last edited February 28, 2025
Text editor powered by tinymce.