||<>|| = Introduction = This page is designed to show how to set up a MythTv installation (nominally on Jaunty) to successfully suspend and resume using the remote control with the mceusb2 receiver. = Verify Pre-requisites = This is the configuration that is known to work. You should be able to apply this to other setups... * Ubuntu 9.04 (Jaunty Jackalope) installed * MythTV running and working * Lirc installed and receiving keypresses If you have done this, then you should be able to trigger suspend on your machine (maybe using a dedicated power button or menu option), get it to resume (maybe using the keyboard) and find that the remote stops working. = Fix Lirc Installation = Out of the box, the mceusb2 receiver has a problem with suspend-resume, and if a client is connected to lircd (e.g. mythfrontend) then it will be pseudo-random whether the device is /dev/lirc0 or /dev/lirc1. However, this can be relatively simply patched by improving the resume functionality of the driver. {{{ #Get the source (and set up dkms) sudo apt-get install lirc-modules-source #Modify the source sudo nano /usr/src/lirc-0.8.4a/drivers/lirc_mceusb2/lirc_mceusb2.c #recompile via dkms sudo dpkg-reconfigure lirc-modules-source }}} At the bottom of lirc_mceusb2.c, you need to modify the exported functions to include .reset_resume: {{{ static struct usb_driver usb_remote_driver = { LIRC_THIS_MODULE(.owner = THIS_MODULE) .name = DRIVER_NAME, .probe = usb_remote_probe, .disconnect = usb_remote_disconnect, #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) .suspend = usb_remote_suspend, .reset_resume = usb_remote_resume, .resume = usb_remote_resume, #endif .id_table = usb_remote_table }; }}} Once you have done this, you should be able to suspend and resume, and still have the remote working. If you want to check this, start a terminal, then execute the command 'irw'. Pressing a button on the remote should result in output. Suspend the machine. When you resume, irw should still be running, and should give you output whenever you press a button on the remote. = Add MythTv Suspend Menu Option = We need to be able to trigger the suspend from within the MythTv frontend. {{{ sudo nano /usr/share/mythtv/mainmenu.xml }}} Add the following button to the *end* of the list: {{{ }}} (I know it says Power Off, but it is just a little white lie). And finally create/edit the file /usr/share/mythtv/myth-suspend.sh: {{{#! #!/bin/sh # This script uses dbus to tell HAL to shut down your computer dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0 }}} Restart MythTv and make sure that you can now suspend and resume using the remote control (by navigating and selecting the new menu option). = Trigger Suspend using the remote = Finally, we need to trigger the suspend by using the power button on the remote. First, modify your startup applications to include irexec. Go to 'System' 'Preferences' 'Startup Applications' and add a new application. Name is 'IrExec', and Command is 'irexec -d'. (Note that this must be done within user context and not via a system level (e.g. rcX) script). {{{ nano ~/.lirc/mythtv }}} Add the following stanza: {{{ begin remote = mceusb prog = irexec button = Power config = /home/mythtv/mythtv_suspend.sh repeat = 0 delay = 0 end }}} Create the file ~/mythtv_suspend_keys (this is the list of keypresses required to trigger the shutdown): {{{ jump mainmenu key escape key escape key up key enter }}} Create the file ~/mythtv_suspend.sh: {{{#! #!/bin/bash #Signify we caught the command beep #Necessary to avoid having the cursor get stuck on the screen when we resume /usr/bin/xwit -root -warp 1920 1080 #Pipe commands into the frontend cat /home/mythtv/mythtv_suspend_keys | netcat -q0 -i 1 localhost 6546 }}} Finally go in to MythTv setup ('General/Setup' 'Setup' 'General' and on about the second or third page make sure that mythfrontend opens a socket for external control). Restart mythfrontend and verify that it works correctly. ---- CategoryVideo