Fireplace on a Raspberry Pi
After not too much work, I was able to finish up the fireplace in our front room. This was a small hack involving a Raspberry Pi. I’ll summarize what worked and then share a few thoughts on what didn’t.
What worked
Here’s the quick summary:
- Formatted a new Raspberry Pi 4B with a fresh OS install.
- In the Raspberry Pi settings, set boot to console.
- Set up a default
fireplace
user, install a 5-minute loopable video of a fireplace, and write a tiny script to invoke it. This lives in the/home/fireplace/kiosk/play-fireplace.sh
directory.
#!/usr/bin/sh
cvlc -Lf fireplace-5min.mp4
I can test this here and confirm it works.
- Set up a systemd service to auto-launch the fireplace on boot: create a small script at
/home/fireplace/kiosk/service-config/fireplace.service
[Unit]
Description=fireplace
[Service]
Type=simple
WorkingDirectory=/home/fireplace/kiosk
User=fireplace
Environment="XDG_RUNTIME_DIR=/run/user/1000"
Environment="DISPLAY=:0"
ExecStart=/home/fireplace/kiosk/play-fireplace.sh
Restart=always
[Install]
WantedBy=multi-user.target
Why multi-user.target
here? Because since we never actually launch to a GUI, graphical.target
isn’t invoked.
- Set up a little install script. `/home/fireplace/kiosk/service-config/install.sh
#!/bin/bash
sudo cp fireplace.service /etc/systemd/system/fireplace.service
sudo chown root:root /etc/systemd/system/fireplace.service
- Run that script!
sudo systemctl enable fireplace
— set fireplace to launch on startupsudo systemctl start fireplace
And we’re good! Fireplace grabs graphics and fires up.
What didn’t work
I originally tried setting this up with a browser in kiosk-mode and a small HTML page to play the video. I encountered a few problems here:
- The rules for Chromium auto-playing videos have become completley Draconian. There used to be a command-line flag you could pass to make it happen, but it doesn’t seem to work anymore. I gave up and switched to Firefox.
- On this configuration, both webgl and playing videos in Chromium and Firefox caused truly awful screen-tearing. I suspect if I’d played around with a lot of flags and switches, I could have improved performance, but where’s the fun in that?
- For reasons I was never able to sort out,
startx
wouldn’t work over an SSH connection without all of the/dev/tty*
devices set tog+r
permission. I wasn’t able to suss out why Xorg would care about TTY permissions, but it was necessary to grant that permission to unstick it.
Anyway, if one wanted to go this road, the command that was closest to working was
startx /usr/bin/firefox --width 1920 --height 1080 --use-gl=egl --noerrdialogs --disable-infobars --kiosk "${URL}" --autoplay-policy=no-user-gesture-required -- -nocursor
The only issue is that the webgl shader I’ve been working on can’t be played directly since I don’t have a browser that won’t tear awfully. I might re-tool it into an OpenGL shader running closer to native code and see if that works… Or I might record 10 minutes of video on a more powerful machine and just let VLC play it!
Comments