vdrd project is a daemon to control VDR.
· starting VDR only when needed for live-viewing or recording
· triggering VDR start via starting the live-view application (xawtv, xine...)
· programming nvram-wakeup timers and automatic shutdown after recording
· error recovery when VDR crashes
Theory of operation
VDR can either function as a settop box, driving a TV set via the video output of a "full-featured" DVB card, or be used with a viewer program to do the actual displaying of video on the PC screen. This viewer may be xawtv or tvtime etc. for "full-featured" DVB cards.
Another solution is to use the xine plugin, in which case xine is the viewer program. In all these cases, the viewer can be started independently from VDR. (This may not be the case for all of the various software decoder plugins, however.)
vdrd is designed to run with such a separate viewer, for the case where VDR itself doesn't need to run all the time. VDR only should be started when recording via a timer or when viewing TV via a viewer (or both at once). When not needed, VDR is shut down, which switches the DVB hardware off and thus saves energy and reduces heat dissipation.
To this end, vdrd watches out for whether the viewer program runs and whether a timer is active.
vdrd creates a FIFO device, into which the viewer program's output should be redirected. Listening on this FIFO tells vdrd whether a viewer is active. vdrd also periodically asks VDR for the next active timer.
Create a "video" user which owns the /video and LIBDIR directories. Edit the compile-time parameters in config.h and Makefile as needed. Edit the perl scripts (loaddevices and vdrshutdown) as needed.
make; make install
The perl scripts are installed setuid root. The main program runs as user "video".
Edit the run-time configuration file vdrd.conf (by default installed in /etc) as needed. You want to adapt at least the list of plugins to load.
Here the following access rights are assumed:
LIBDIR is owned by video.video, mode 700. This protects the setuid scripts which could wreak havoc if called by a user. Nobody should need access to the config files directly, anyway.
RUNDIR is owned by video.video, mode 755. The FIFO is in this directory, so anyone can access it. Use mode 750 for the directory to restrict access to the video group.
Note that the builtin shutdown control of VDR is not used; vdrd takes over this part. So VDR is started without an -s argument and its "idle timeout" should be set to zero.
Start vdrd on system startup via an init script. (There is one in the examples directory.) To view TV, start the viewer program with output into the FIFO. Make sure that at least one character is written into the FIFO. (There are suitable starters for xawtv in the examples directory.)
vdrd now will start VDR, and will stop it again when xawtv exits.
It also will start VDR when a recording timer is about to start and stop it after the recording is finished.
Whenever vdrd decides that VDR can be stopped, it will shut down the computer if nobody is logged in. When vdrd itself gets stopped by SIGTERM (usually during the system shutdown sequence), it sets a wakeup timer via "nvram-wakeup". This can be customized in the shutdown script.
When vdrd gets a SIGHUP signal, it re-reads the configuration file. If vdr is running at this moment, it is stopped and immediately restarted. This can be used to change options for vdr.