Archive:Suspend and wake in Ubuntu: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Pashdown
(comma)
mNo edit summary
 
(34 intermediate revisions by 13 users not shown)
Line 1: Line 1:
=Enabling Suspend / Wake on Ubuntu Linux=
{{cleanup}}
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.


==Enable ACPI S1/S3 Suspend in your BIOS==
=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.


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.
== Enable ACPI S1/S3 Suspend in your BIOS ==


==Edit /etc/Policykit/PolicyKit.conf==
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.


Edit '''/etc/Policykit/PolicyKit.conf''' to add privileges for the '''xbmc''' account:
== Add Custom Actions to PolicyKit ==
<pre><config version="0.1">
Make sure the following packages are installed.
    <match user="root">
        <return result="yes"/>
    </match>
    <match user="xbmc">
        <return result="yes"/>
    </match>
    <define_admin_auth group="admin"/>
</config>
</pre>
 
==Add Custom Actions to PolicyKit==


<source lang="bash">sudo apt-get install policykit-1 devicekit-power</source>
<source lang="bash">sudo apt-get install policykit-1 upower acpi-support consolekit</source>


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


<pre>org.freedesktop.devicekit.power.suspend
<pre>org.freedesktop.upower.suspend
org.freedesktop.consolekit.system.stop</pre>
org.freedesktop.consolekit.system.stop</pre>


Create a file '''/var/lib/polkit-1/localauthority/50-local.d/custom-actions.pkla''' with the following contents:
Create a file '''/var/lib/polkit-1/localauthority/50-local.d/custom-actions.pkla''' with the following contents:
<pre>[Actions for xbmc user]
<pre>
[Actions for xbmc user]
Identity=unix-user:xbmc
Identity=unix-user:xbmc
Action=org.freedesktop.devicekit.power.*;org.freedesktop.consolekit.system.*
Action=org.freedesktop.upower.*;org.freedesktop.consolekit.system.*;org.freedesktop.udisks.*
ResultAny=yes
ResultInactive=no
ResultActive=yes
ResultActive=yes
ResultAny=auth_admin
</pre>
ResultInactive=yes</pre>


[http://forum.xbmc.org/showpost.php?p=448088&postcount=54 Credit to '''kroete''']
NOTES:


==Disable Usbcore Autosuspend==
(1) You may have to comment out the existing 20-xbmclive.pkla as well until this issue is resovled:
[http://trac.kodi.tv/ticket/11581]


Add a boot option to grub to disable the usbcore autosuspend.  This bug exhibits itself as immediately waking after suspension.
(2) With xbmc Eden on Ubuntu 12.04 it was necessary to change in the above "ResultInactive=no" to "ResultInactive=yes".


Edit '''/etc/default/grub''' and add '''usbcore.autosuspend=-1''' to '''GRUB_CMDLINE_LINUX_DEFAULT'''. Example:
[http://forum.kodi.tv/showpost.php?p=448088&postcount=54 Credit to '''kroete''']
 
== Disable Usbcore Autosuspend ==
 
Add a boot option to grub to disable the usbcore autosuspend. This bug exhibits itself as immediately waking after suspension.
 
Edit '''/etc/default/grub''' and add '''usbcore.autosuspend=-1''' to '''GRUB_CMDLINE_LINUX_DEFAULT'''. Example:


<pre>GRUB_CMDLINE_LINUX_DEFAULT="quiet splash xbmc=autostart,noredir usbcore.autosuspend=-1"</pre>
<pre>GRUB_CMDLINE_LINUX_DEFAULT="quiet splash xbmc=autostart,noredir usbcore.autosuspend=-1"</pre>
Line 51: Line 49:
<source lang="bash">sudo update-grub</source>
<source lang="bash">sudo update-grub</source>


==More PolicyKit Settings==
= Remote Suspend / Wake =
 
Using an IR remote to suspend and wake your XBMC HTPC is much easier than getting off the couch.
<source lang="bash">sudo polkit-auth --user xbmc --grant org.freedesktop.hal.power-management.suspend
sudo polkit-auth --user xbmc --grant org.freedesktop.hal.power-management.hibernate
sudo polkit-auth --user xbmc --grant org.freedesktop.hal.power-management.reboot
sudo polkit-auth --user xbmc --grant org.freedesktop.hal.power-management.shutdown
sudo polkit-auth --user xbmc --grant org.freedesktop.hal.power-management.reboot-multiple-sessions
sudo polkit-auth --user xbmc --grant org.freedesktop.hal.power-management.shutdown-multiple-sessions
</source>


=Remote Suspend / Wake=
* [http://www.loggn.de/linux-xbmc-aus-bereitschaftsmodus-per-mce-fernbedienung-aufwecken/ HowTo for Ubuntu 12.04 (Kernel 3.2) - XBMC - Wakeup with MCE remote control]
Using an IR remote to suspend and wake your XBMC HTPC is much easier than getting off the couch.
* [http://www.loggn.de/linux-probleme-nach-dem-bereitschaftsmodus-fernbedienung-netzwerk-und-sound-funktionieren-nicht/ HowTo for Ubuntu 12.04 (Kernel 3.2) - XBMC - Problems after resume from sleep]


==Enable Wake on USB Activity==
== 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.
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:
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:


<source lang="bash">sudo sh -c 'echo "USB0" > /proc/acpi/wakeup'</source>
<source lang="bash">sudo sh -c 'echo "USB0" > /proc/acpi/wakeup'</source>


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'''.
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'''.


<source lang="bash">echo "USB0" > /proc/acpi/wakeup</source>
<source lang="bash">echo "USB0" > /proc/acpi/wakeup</source>
Line 81: Line 72:
It should show '''"enabled"''' in the 3rd column after the device you set.
It should show '''"enabled"''' in the 3rd column after the device you set.


==Enable Wake on Other Devices==
on Ubuntu 10.10 Maverick, Kernel 2.6.35-* You Should enable sysfs based wakeup on Remote Control device,
[[Enable_Wake-On-Device|More information on this page]]
 
on my system it is done by
 
<source lang="bash">echo enabled > /sys/bus/usb/devices/2-4/power/wakeup</source>
 
You can find which is Your device by grepping dmesg, for me it is mceusb
 
<source lang="bash">dmesg |grep mceusb</source>
 
== 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.kodi.tv/showthread.php?t=76944


==Use an Xbox Remote Start-up Kit==
== 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.
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.


[http://forum.xbmc.org/showthread.php?t=64328 One example of how to install a XERC 2 XE is located here.]
[http://forum.kodi.tv/showthread.php?t=64328 One example of how to install a XERC 2 XE is located here.]


==Fix the Lirc Device Increment Bug==
== Fix the Lirc Device Increment Bug ==
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''' :
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''' :


<source lang="bash">#!/bin/sh
<source lang="bash"># Script to disable lirc before suspend and restart after wake.
# Script to disable lirc before suspend and restart after wake.


case "${1}" in
case "${1}" in
         suspend|hibernate)
         suspend|hibernate)
if [ "$(pidof xbmc.bin)" ] ; then
wget -q -b -O /dev/null -o /dev/null "http://127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=LIRC.Stop"
fi
                 /etc/init.d/lirc stop
                 /etc/init.d/lirc stop
                 ;;
                 ;;
         resume|thaw)
         resume|thaw)
# If remote still does not work after suspend, uncomment the lines below.
# Note you may need to change "lirc_mceusb". See output from 'sudo lsmod | grep lirc' for module name.
                #rmmod lirc_mceusb
                #modprobe lirc_mceusb
                 /etc/init.d/lirc start
                 /etc/init.d/lirc start
if [ "$(pidof xbmc.bin)" ] ; then
wget -q -b -O /dev/null -o /dev/null "http://127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=LIRC.Start"
fi
                 ;;
                 ;;
esac
esac

Latest revision as of 01:01, 20 August 2020

Cleanup.png This page or section may require cleanup, updating, spellchecking, reformatting and/or updated images. Please improve this page if you can. The discussion page may contain suggestions.


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.

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.

Add Custom Actions to PolicyKit

Make sure the following packages are installed.

sudo apt-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:

[Actions for xbmc user]
Identity=unix-user:xbmc
Action=org.freedesktop.upower.*;org.freedesktop.consolekit.system.*;org.freedesktop.udisks.*
ResultAny=yes
ResultInactive=no
ResultActive=yes

NOTES:

(1) You may have to comment out the existing 20-xbmclive.pkla as well until this issue is resovled: [1]

(2) With xbmc Eden on Ubuntu 12.04 it was necessary to change in the above "ResultInactive=no" to "ResultInactive=yes".

Credit to kroete

Disable Usbcore Autosuspend

Add a boot option to grub to disable the usbcore autosuspend. This bug exhibits itself as immediately waking after suspension.

Edit /etc/default/grub and add usbcore.autosuspend=-1 to GRUB_CMDLINE_LINUX_DEFAULT. Example:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash xbmc=autostart,noredir usbcore.autosuspend=-1"

Update grub:

sudo update-grub

Remote Suspend / Wake

Using an IR remote to suspend and wake your XBMC HTPC is much easier than getting off the couch.

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:

sudo sh -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

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.kodi.tv/showthread.php?t=76944

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.

One example of how to install a XERC 2 XE is located here.

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 :

# Script to disable lirc before suspend and restart after wake.

case "${1}" in
        suspend|hibernate)
		if [ "$(pidof xbmc.bin)" ] ; then
			wget -q -b -O /dev/null -o /dev/null "http://127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=LIRC.Stop"
		fi
                /etc/init.d/lirc stop
                ;;
        resume|thaw)
 # If remote still does not work after suspend, uncomment the lines below. 
 # Note you may need to change "lirc_mceusb". See output from 'sudo lsmod | grep lirc' for module name.
                #rmmod lirc_mceusb
                #modprobe lirc_mceusb
                /etc/init.d/lirc start
		if [ "$(pidof xbmc.bin)" ] ; then
			wget -q -b -O /dev/null -o /dev/null "http://127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=LIRC.Start"
		fi
                ;;
esac

Make sure the script is executable:

chmod 755 /etc/pm/sleep.d/90_lirc