1 Enabling Suspend / Wake / Shutdown / Power off on Ubuntu Linux

First, test XBMC to see if it already suspends. You may not need any extra setup. If it does not suspend properly, one or more of the following techniques may be necessary. Go through them in order and stop once you have a working suspend and wake. Be certain to test it more than once, there is a bug that will express itself as not suspending after the first wake is successful.

1.1 Enable ACPI S1/S3 Suspend in your BIOS

Make sure your ACPI S1/S3 is enabled in your BIOS. There are as many ways to do this as there are different BIOSes out there. Refer to your motherboard documentation for details.

1.2 Add Custom Actions to PolicyKit

Make sure the following packages are installed.

sudoapt-get install policykit-1 upower acpi-support consolekit

Now run "pkaction" and verify that the following are present.

org.freedesktop.upower.suspend
org.freedesktop.consolekit.system.stop

Create a file /var/lib/polkit-1/localauthority/50-local.d/custom-actions.pkla with the following contents:

2.1 Enable Wake on USB Activity

If your IR receiver is plugged into a USB port. You can have Linux recognize IR traffic on the USB bus as a signal to wake XBMC. This method can have the drawback of waking XBMC unnecessarily because you're using the remote for other devices.

First find which USB bus your IR receiver is connected to. The command lsusb can be somewhat useful for determining this, or you can just start at 0 and work your way up until you find it. The command to wake upon USB traffic is:

sudosh-c'echo "USB0" > /proc/acpi/wakeup'

Replace USB0 with USB1 and so on until you find it. Once you do, add it to your startup by editing /etc/rc.local and putting the following line before exit 0.

echo"USB0">/proc/acpi/wakeup

You can verify this is set after boot by running:

cat/proc/acpi/wakeup

It should show "enabled" in the 3rd column after the device you set.

on Ubuntu 10.10 Maverick, Kernel 2.6.35-* You Should enable sysfs based wakeup on Remote Control device,

on my system it is done by

echo enabled >/sys/bus/usb/devices/2-4/power/wakeup

You can find which is Your device by grepping dmesg, for me it is mceusb

dmesg|grep mceusb

2.2 Ubuntu Kernel bug

If you are running a recent Ubuntu lucid install, and your device refuses to resume from standby even while the correct wakeup devices are set in /proc/acpi/wakeup. It could be caused because of a bug in the current Ubuntu kernel. Kernel versions starting from 2.6.32-23 are affected by this bug. A possible solution is to downgrade your kernel to 2.6.32-22. More information about this: http://forum.xbmc.org/showthread.php?t=76944

2.3 Enable Wake on Other Devices

2.4 Use an Xbox Remote Start-up Kit

There are a few kits out there that can be soldered into a classic Xbox to enable power-on by pressing a set remote button on the Xbox DVD kit. These can be adapted to a PC, and carries the advantage of working regardless of the state of the system in the same way a power button does.

2.5 Fix the Lirc Device Increment Bug

NOTE: You have to enable control of XBMC via HTTP for this to work.
If your IR remote does not work after waking from sleep, you most likely have this bug. The IR software for Linux, Lirc, will create a new device /dev/lirc1 because it presumes the old device /dev/lirc0 is in use by another process. This confuses XBMC and you end up with a non-working remote. The solution is to shutdown Lirc before suspension and then start it back up after wake. This is done by creating a script at /etc/pm/sleep.d/90_lirc :