Home > Mythtv > Howto: Mythtv with acpi wakeup and mythwelcome

Howto: Mythtv with acpi wakeup and mythwelcome

September 9, 2008 Leave a comment Go to comments

UPDATE:Newer kernels (>2.6.22) handle wakeup alarms differently than in this howto, take a look at the official mythtv howto to cover newer kernels.

I am running an Epox 8rda+ (nforce2 chipset) with MythBuntu and will try to show, how to setup this mainboard with ACPI and mythwelcome, so that it starts with scheduled recordings and will shutdown automatically, when recording is finished.

* A working mythbuntu installation with Backend and Frontend on the same machine
* Disabled acpi function in the BIOS
* BIOS runs in UTC
* Epox 8rda+ board (I can only somewhat guarantee the functionality of this howto with this mainboard ! )
* Mythbuntu latest (with fixes) – although this howto should work basically with other combinations too – but just basically
* use of /proc/acpi/alarm
* You simultanously look at the mythtv wiki
* You don’t expect this howto to be perfect or complete

1. Setup of ACPI
The information is well described in the Mythtv Wiki so I will only point out the most important information for the mentioned mainboard, the Epox 8rda+.
The current version of mythbuntu runs kernel 2.6.24-19 – although, in contrary to the WIKI and in combination with the Epox Board, it uses /proc/acpi/alarm rather than /sys/class/rtc/rtc0/wakealarm like mentioned in the wiki for kernels >=2.6.22.

First of all, make sure powersaved ist installed by invoking:

sudo apt-get install powersaved

You can check the successfull installation with the command

powersave -S

wich should display:


Then modify your /etc/init.d/hwclock.sh as described in the mythtv wiki.

So far, so good. Next step will be to check, if ACPI wakeup basically works. Instead of the way the Wiki describes the function test, which won’t work with the Epox 8RDA+ because of malformed year string, we will first check the current system time:


Which also will inform us about, which timezone Mythbuntu is running at – in my case CEST – which is central european summer time. The BIOS itself normally operates with UTC – Universal time coordinated. This knowledge about the difference between your current mythbuntu system time and the UTC is very important as you have to include this information with your ACPI time settings.
CEST = UTC +2 !!!


For instance, the current time is 10th September 2008 – 12:20:00 CEST
that means, if we want to add 5 minutes for a boot up in 5 minutes for testing purposes, we have to set 10:25 !!!

sudo echo "2008-09-10 10:25:00" > /proc/acpi/alarm

shortly after that you have to shutdown your computer with the following command:

sudo shutdown -h now

Now wait and see…..

If the system won’t come up, you either didn’t change the date and time in my example according to your current time and date 😉 , your wakeup in the BIOS is enabled or something else is wrong. In this case, use the comment function or ask on different mythtv or mythbuntu pages.

If it booted up, then let’s go on to section 2 …

2. Permissions for the user who runs the backend/frontend:

First of all, changing permissions for users lower than root is always a security risk. As my mythtv box isn’t reachable by the internet and my network is trustworthy, I never spent a second thinking about risks when playing around with permissions. Keep that in mind !

Permissions are very important for mythtv to be able to set the wakeup time through the backend / frontend. As you have seen above, when typing sudo echo xyz, you had to type in your root password. This is a problem as you won’t be able to give the backend the desired password, if it asks for.
So, we have to edit the /etc/sudoers file.

First, check which user is running backend and frontend:

ps aux | grep myth

In my case, backend is run by the user mythtv and the frontend by my user name, Rock.

So, let’s give em both a bunch of permissions:
The user Rock is part of the admins group in /etc/group:

for the user mythtv, I gave him all I could think of:
%mythtv ALL = NOPASSWD: /sbin/shutdown, /usr/bin/MythWakeSet, /proc/acpi/alarm, /usr/bin/MythShutdownCheck, /etc/init.d/mythtv-backend, /usr/bin/mythshutdown, /usr/bin/welcome, /usr/bin/mythwelcome, /usr/bin/eject, /bin/mount, /bin/umount, /usr/bin/nuvexport, /usr/bin/nuvexport-xvid, /bin/sh

and for my user Rock:

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
rock mythtvbox = NOPASSWD: SHUTDOWN_CMDS,/usr/bin/MythWakeSet, /proc/acpi/alarm, /usr/bin/MythShutdownCheck, /etc/init.d/mythtv-backend, /usr/bin/mythshutdown, /usr/bin/welcome, /usr/bin/mythwelcome, /usr/bin/eject, /bin/mount, /bin/umount, /usr/bin/nuvexport, /usr/bin/nuvexport-xvid, /bin/sh

Again, this isn’t very smart, nor is it anyhow somewhat secure, nor I am sure, that this is all of my privileges I have set when struggling with mythtv, but I don’t care in my case – it is up to you to limit restrictions as you think, it would be smart.
Just remember, that all commands invoked by mythtv, starting, rebooting, shutting down, running scripts which have to be run via sudo should be listed with NOPASSWD
Whatever, just play around what you might need.

So, as your user is somewhat root in many operations, lets go to the setup section of mythtv:

3. Setting up mythbackend

As for mythbuntu, you have to go into mythbuntu control centre:
Frontend —> Config –> Config –> Mythbuntu

Type in your passwd.
In the mythbuntu control center, go to –> Mythtv Configuration –> Start Mythtv-Setup:
Hit OK when it asks you, if it should close the backend.

In the mythtv setup screen, hit General.
Then press Forward till you reach the screen Shutdown/Wakeup Options:
Fill in like I have done in my setup:

mythbackend screenshot

mythbackend screenshot

Get out of mythtv-setup, you can answer No if it asks you to run mythfilldatabase.

Other distributions:
Just run mythtv-setup out of an xterm.

A quick word about the Pre-Shutdown check command:
There is a way to let the backend check, if for instance someone is connected through ssh or, I guess, vnc too – but it never really worked for me, so I have set it to return 0, which means, jepp backend, you can reboot.
If you want to play around, use instead:
mythshutdown –check
or if doesn’t work:
sudo mythshutdown –check.

Now, you might have noticed a command such like MythWakeSet – we’ll need that piece of script.

Make a file named MythWakeSet and fill it with the following content:

# MythWakeSet
# set mythtv wake-up time with UTC-adjusted time

# temp file for working with time

# store the wake time passed from mythbackend
echo $1\ $2 > $temp_stamp

# Read the date in *locale* time format and tag the time-zone info to the wake time
localeadd=$(/bin/date -f $temp_stamp +%F\ %T\ %z)
echo $localeadd > $temp_stamp

# adjust this to UTC and store the final wake time
utcadj=$(/bin/date -u -f $temp_stamp +%F\ %T)

# set the alarm
echo $utcadj > /proc/acpi/alarm

Then copy the file to /usr/bin and make it executable:

sudo cp MythWakeSet /usr/bin
sudo chmod +x /usr/bin/MythWakeSet

Again, this only applies to my board and the prequesites, that the BIOS runs UTC !
For other configurations, check other howtos.

Just one information:
For newer installs, the command described in the mythtv wiki:
mythshutdown –setwakeup $time
won’t work – as the command has changed a little bit throughout 0.21. How it will work though – no clue 😉

Now the backend should be correctly set.
Let’s give it a try:
Program a show which starts lets say in about 15 minutes – just to be absolutely sure !
Keep in mind, that the user mythtv has to be set as NOPASSWD for the command /usr/bin/MythWakeSet in the /etc/sudoers file plus full access to /proc/acpi/alarm !!!!
Shut the box down and wait, or drink a coffee, smoke or whatever you intend to use during such unexpected downtimes.

If it comes up correctly withtin 15 minutes – congrats, let’s proceed to the next step – if not, again comment function or whatever you do to solve issues.

4. MythWelcome

As you have successfully finished part 3 of this howto, you might have noticed, that the box did boot up correctly, recorded the show – and then – yepp, stood there idle. But, this isn’t the way we want mythtv to act, we want it to shutdown after recording – imagine a recording while you’re away – the box will run till you come home and push the shutdown button – for this problem, there is a neat tool named MythWelcome, which basically acts as decider, whether it should shut down or not.

So, lets configure it.

Go back to the desktop (which means, close mythfrontend) and open an xterm, and type in:

mythwelcome --setup

Set it up like in my screen:

mythwelcome setup

mythwelcome setup

For mythbuntu only:
Mythbuntu uses xfce so we have to exchange the startup of mythfrontend with mythwelcome.
So, get into your home directory, into the directory .config/autostart and edit the mythtv.desktop file as following:

[Desktop Entry]
Name=MythTV Frontend
Comment=A frontend for all content on a mythtv-backend
GenericName=MythTV Viewer

For other distributions, check forums, howtows ….

This will start mythwelcome instead of mythfrontend – but don’t panic, mythfrontend is still available and will run with one click (or push on the remote).

So, reboot or restart gdm – you’ll see mythwelcome, whining about, that it will reboot in 120 seconds.
That should do it now – mythwelcome should count down from 120 seconds (you can set the time in mythtv-setup – > look at the screenshot under 3) till it shuts down – enough time for me personally to hit the RETURN button or the OK on my remote to start mythfrontend – as mythfronted is running, mythwelcome won’t shut the box down.

That means, and this isn’t somewhat perfect, you have to get into mythfrontend within 120 seconds when you start up mythtv manually, or mythwelcome will again shutdown the box. I haven’t figured out a solution for his problem, but as I don’t really care, I really didn’t put much effort in it.

Program a recording, close mythfrontend – mythwelcome will appear – and the box will shutdown in 120 seconds after that – then wait till it boots (hopefully) up for recording – mythwelcome will show you, that it will record and after that, it will shutdown.

That’s it for now – this howto is far from perfect as I have played around months to get it working – so I might have left out some particular interesting and important information. This is just meant to help you, if you are stuck like I was.

Categories: Mythtv
  1. Pierre
    June 7, 2009 at 11:30 pm

    Thanks for the effort, but I just can’t get over how obfuscated and complicated this process is. And instructions in the wiki only cause more confusion. For example, the noobie is told to change certain files. The instructions are


    What’s “==>” doing in a config or ini file??

    I’ve given up.

  2. Pierre
    June 8, 2009 at 12:39 am

    sudo echo “2008-09-10 10:25:00” > /proc/acpi/alarm

    doesn’t work for me (jaunty)

    “bash: /proc/acpi/alarm: No such file or directory”

  3. Rock
    June 13, 2009 at 2:04 pm

    Hey Pierre,

    sorry for the late answer. The ===> has to be left out, it is just to make the changes more visible.
    This means that you have have to change/add just HWCLOCKACCESS=no, so without the ==>

    To your second question:
    Ubuntu has changed the alarm due to kernel changes, this howto covers the handling before these changes. I would suggest you you follow the official howtos, where the current location of alarm function and the handling is very well described.

  1. December 3, 2009 at 8:56 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: