You are not logged in.
Okay, I'm running in circles now.
I'm trying to create a digital sign that boots from a flash drive into a modified archiso image to display a video stream.
Everything from boot to stream works great, but as soon as it loses connectivity the stream drops, the media player (i'm not tied to any in particular) exits and then nothing. I have a cron job that asks "are you running? no? okay start" every minute, but that seems like a hack. What I would ideally like to do is run a systemd service that handles the initial execution and future restarts.
Right now I have a very barebones service that runs and then restarts a script:
[Unit]
Description=Run video stream
[Service]
ExecStart=/usr/local/bin/stream.sh
Restart=always
[Install]
WantedBy=multi-user.targetstream.sh contains:
#!/bin/bash
export DISPLAY=:0
mplayer -fs [stream address]The system setup is a bare archiso plus xorg, i3, and mplayer.
I was able to get all of the monitors on my dev machine to turn black with a cursor (and access to the now-invisible apps below) by prepending the mplayer command directly with DISPLAY=:0, but no video. I am able to get mplayer to play properly by sshing into the box as the same user and running the script as-is by hand. Everything is being ran as root (out of desperation).
This is the first time i've worked with creating systemd services, though I have googled and searched and rtfm-ed for a few days now. I may still be ignorant to something simple.
Does anyone have any ideas?
Thank you in advance!
Offline
Offline
Are there any error messages in the journal, when you try to start the unit?
Offline
I would use a user service not a system service.
I tested that service put in ~/.config/systemd/user :
$ cat videostream.service
[Unit]
Description=Run video stream
[Service]
ExecStart=/usr/bin/vlc http://teleclub.fr/gloubi.mp4
Restart=alwaysthe line
export DISPLAY=:0
is no longer required, because the DISPLAY variable is already exported from /etc/X11/xinit/xinitrc.d/50-systemd-user.sh normally launched in the .xinitrc script.
I tested that with:
systemctl --user start videostream
If I quit vlc manually, it is restarted as expected.
To have the service starting after login, you need to enable it with:
systemctl --user enable videostream.
Offline
Why even make this a service? Just run it in a loop:
while :; do mplayer -fs [stream address]; done"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Yes! The user service was exactly what I needed, thank you berbae. I combined that with Trilby's while loop, thank you as well! I'll be impressed if this thing finds a way to stop running.
--
Dear future googler, binger, seeker of how to keep a video running, here is my service file. I'm not yet sure entirely of what I'm doing, but this worked:
~/.config/systemd/user/stream.service
[Unit]
Description=Run video stream
[Service]
ExecStart=
ExecStart=/opt/stream.sh
Restart=always
RestartSec=10The RestartSec was important in my case, systemd seems to protect itself from endless loops of failure (mplayer gives up quickly after a dropped connection)
/opt/stream.sh
#!/bin/bash
mplayer -fs [url]Enable:
$ systemd enable --user stream.serviceI don't want to be spreading misinformation, so if anyone would like to add to this please do - I just hate to end this thread with "Now it works, okay bye"
Thanks again!
Last edited by 5591 (2015-12-07 16:14:13)
Offline