I've only tested with RASPBIAN STRETCH WITH DESKTOP November 2017 version
sudo raspi-config
Select “Boot Options” then “Desktop/CLI” then “Console Autologin”
GOARM=6 GOARCH=arm GOOS=linux go build -o rpi_pic
To Install:
- copy compiled binary to
/home/pi/rpi_pic
- copy config.yaml to
/home/pi/config.yaml
- copy video files to match BasePath in config.yaml
The best method (that I've found) to running a go program on a Raspberry Pi at startup is to use the systemd files. systemd provides a standard process for controlling what programs run when a Linux system boots up. Note that systemd is available only from the Jessie versions of Raspbian OS.
Create a service file at the following location:
sudo touch /lib/systemd/system/rpi_pic.service
Edit the file to look like this:
[Unit]
Description=Video Shuffler
After=multi-user.target
[Service]
Type=idle
ExecStart=/home/pi/rpi_pic
[Install]
WantedBy=multi-user.target
This defines a new service called “Video Shuffler” and we are requesting that it is launched once the multi-user environment is available. The “ExecStart” parameter is used to specify the command we want to run. The “Type” is set to “idle” to ensure that the ExecStart command is run only when everything else has loaded. Note that the paths are absolute.
The permission on the unit file needs to be set to 644 :
sudo chmod 644 /lib/systemd/system/rpi_pic.service
Now the unit file has been defined we can tell systemd to start it during the boot sequence :
sudo systemctl daemon-reload
sudo systemctl enable rpi_pic.service
Reboot the Pi and your custom service should run:
sudo reboot
sudo systemctl stop rpi_pic.service
recompile and copy file
sudo reboot
Config options can be change by editing
Shuffle: true
Randomize video playback. Videos are randomized on every reboot.
Autostart: false
Start plaing a video once OS has loaded. Otherwise press button to start.
BasePath: /home/pi/Videos/Simpsons*
Golang filepath.Glob pattern (https://golang.org/pkg/path/filepath/#Glob).
For pattern info see: https://golang.org/pkg/path/filepath/#Match