Plugins for automatic shutdown and wakeup
The autoshutdown plugins might be what your are looking for, if you do not want to have your freevo box running all the time, but nevertheless be able to record everything no matter at what time of the day it is coming.
This plugin provides a improved shutdown plugin as a replacement of the original shutdown plugin. At every shutdown it programs the system for a wakeup at the start time of the next scheduled recording. At the moment two different wakeup methods are supported: acpi and nvram. Moreover there is also a second plugin named autoshutdown.autoshutdowntimer, which shuts down the system automatically after a certain time of idleness. It checks for menu activity, running recordings and (if you provide a list) also for other important programs which might be running in the background like encoding jobs and shuts down the system, if it is safe. There is a menu entry in the shutdown submenu for pausing/resuming this timer.
The autoshutdown plugin
This plugins are activated by default now in freevo_config.py:
plugin.remove('shutdown') plugin.activate('autoshutdown', level=90) plugin.activate('autoshutdown.autoshutdowntimer')
To make use of this plugin you must allow a system shutdown from freevo's menu
ENABLE_SHUTDOWN_SYS = 1
if you do not run freevo as root, you must use sudo for the shutdown commands
SHUTDOWN_SYS_CMD = 'sudo shutdown -h now' RESTART_SYS_CMD = 'sudo shutdown -r now'
if you want a popup for confirmation when you select to shutdown the system, you should set this:
AUTOSHUTDOWN_CONFIRM = True
Set the timeout in minutes after which the system is shutdown.
This option is for testing, set it to True to disable the actual shutdown command.
The processes in this list will prevent an automatic shutdown. If there are important programs that should not be interrupted, then add them to this list. Set to None if a shutdown is always allowed.
AUTOSHUTDOWN_PROCESS_LIST = [ 'tv_grab', 'mplayer' ]
Set a default time at which to always wakeup even if there are no recordings scheduled. The time is specified in localtime 24 hour format. Set this to None to disable default wakeup time.
AUTOSHUTDOWN_DEFAULT_WAKEUP_TIME = "19:00"
Set the next variable to True to always wakeup at the default wakeup time. Set to False to only wakeup at the default wakeup time when no recordings are scheduled.
AUTOSHUTDOWN_FORCE_DEFAULT_WAKEUP = True
The number of minutes that may be spent idle until the next scheduled recording or default wakeup. That is, if the gap between "now" and the next recording or default wakeup is less than the allowed idle time then a shutdown is not performed but the system is left running. Use this to minimize the number of shutdown/boot sequences when many short programs are recorded in a short period of time.
AUTOSHUTDOWN_ALLOWED_IDLE_TIME = 15
You have to choose which wakeup method you want to use. There are two methods availlable acpi or nvram, depending on what you prefer and which method is supported by your bios.
AUTOSHUTDOWN_METHOD = 'acpi'
The nvram methode uses a program which manipulates the Non-Volatile RAM of your bios. You will need the module nvram for your kernel and the program nvram-wakeup. See http://sourceforge.net/projects/nvram-wakeup for more information.
Path to nvram-wakeup and options. Options can be used to specify a config file.
AUTOSHUTDOWN_WAKEUP_CMD = "/usr/bin/nvram-wakeup" AUTOSHUTDOWN_NVRAM_OPT = "--syslog"
If you have one of the bioses that needs a reboot for nvram to work correctly, you must set this variable and also set the correct bootloader options. Read the nvram-wakeup documentation about this topic.
You must set the following to True or False, as the plugin assumes True if not set.
The following variables are only needed when your bios needs a reboot, and you have set the above variable to True.
Set to "GRUB" or "LILO":
AUTOSHUTDOWN_BOOT_LOADER = "GRUB"
Grub needs to write to /boot/grub/grub.conf. Set the command and options to remount the /boot partition writeable. Set to None if this is not needed.
AUTOSHUTDOWN_REMOUNT_BOOT_CMD = "/bin/mount" AUTOSHUTDOWN_REMOUNT_BOOT_OPT = "/boot -o remount,rw"
Grub 1 (a.k.a. grub-legacy) can then be set to poweroff the system after reboot.
AUTOSHUTDOWN_GRUB_CMD = "/sbin/grub-set-default 0" AUTOSHUTDOWN_GRUB_OPT = "0"
For grub2 (that is installed by latest Ubuntu, and Debian/squeeze), the instructions in this page will help you.
Lilo command with options that will reboot and poweroff the system.
AUTOSHUTDOWN_LILO_CMD = "/sbin/lilo" AUTOSHUTDOWN_LILO_OPT = "-R PowerOff"
An easier way is to use acpi, (if your bios supports it). This methode uses the wakeup on alarm function that most bioses have. The wakeup time is set by a simple
echo 2004-08-02 20:15:00 >/proc/acpi/alarm
The problem is that only the time is used by the bios and not the date, this means then that your system will wakeup every day at 20:15. (For me not really a problem, because my freevo box is running once a day anyway).
On more recent kernels, the above /proc entry is not present. Now the state of the RTC is read trhu /proc/driver/rtc and is written in /sys/class/rtc/rtc0/wakealarm (seconds since the epoch). See the RTC man page, the file Documentation/rtc.txt in kernel sources, and the documentation at http://www.mythtv.org/wiki/ACPI_Wakeup .
On most mainboards you will have to play with "Wake on Timer", "Resume on Alarm", "RTC Alarm Resume" or similar things for the acpi wakeup method to work. Sometimes these must be enabled and sometimes not.
If you want to use acpi, you need to create a small script:
#!/bin/sh echo "$1" >/proc/acpi/alarm
You have to be root or use sudo for this to work.
Then tell freevo to use it:
AUTOSHUTDOWN_WAKEUP_CMD = 'sudo /PATH/TO/set_acpi.sh'