0

Enabling Wake on USB in Kodi

Posted in Linux

For those lucky Kodi users still owning an NYXBoard Hybrid, wake on USB is essential for a seamless HTPC experience. Below I’ll explain each step in getting that happening as well as some skin customisations to make things a little nicer down the road.

Wake on USB comes in 2 stages:

  1. Enabling it in the BIOS
  2. Enabling it in the OS

For this tutorial I’m running an Intel NUC 54250WYK with OpenELEC.

The BIOS

Unfortunately every BIOS is different. Some motherboards will support wake on USB, some won’t. Check your motherboards manual to find out more.

As for my NUC, I’m on BIOS version 0038 released on 2015-10-04. Go to Advanced – Boot – Boot Configuration and under Boot Devices make sure USB is checked. Hit F10 to save and exit.

Boot from USB BIOS setting

 

OpenELEC

I have my NYXBoard’s USB dongle plugged into one of my NUCs front USB ports. I need to find out which USB port it is, and enable wakeup for that port.

  • Find the port:
    1
    2
    3
    4
    5
    
    # lsusb
    Bus 001 Device 005: ID 058f:6254 Alcor Micro Corp. USB Hub
    Bus 001 Device 004: ID 22b8:003b Motorola PCS 
    Bus 001 Device 002: ID 8087:8000 Intel Corp. 
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  • Extract the second half of the bus ID. In my case my ID is 22b8:003b so I just want 003b. Now find this device in /sys/bus/usb/devices:
    1
    2
    
    # grep 003b /sys/bus/usb/devices/*/idProduct
    /sys/bus/usb/devices/1-1.2/idProduct:003b
  • The location of my device is 1-1.2. Use this location to see if wakeup is enabled for the device:
    1
    2
    
    # cat /sys/bus/usb/devices/1-1.2/power/wakeup
    disabled
  • Enable wakeup for this boot:
    1
    
    sudo sh -c 'echo "enabled" > /sys/bus/usb/devices/1-1.2/power/wakeup'
  • Enable wakeup for future boots. Add the following to .config/autostart.sh (This file exists in OpenELEC. For other OS’s, you probably want /etc/rc.local):
    1
    2
    
    echo USB1 > /proc/acpi/wakeup
    echo enabled > /sys/bus/usb/devices/1-1.2/power/wakeup

After all of the above is complete, I can now go to Power – Suspend (My NUC slowly pulses its blue suspend light) and use my NYXBoard’s power button to turn the NUC back on.

Thanks to use teeedub for his helpful post on the kodi forums.

 

Optimizing the Theme

Even with wake on USB working, it still only works when the NUC is suspended – not shut down. This needs to be fixed with a theme modification.

Create a modifiable copy of Confluence

The confluence theme can’t be modified directly as OpenELEC has a read-only filesystem, so we’ll first create a copy of the theme into our  appropriate user directory:

1
cp -r /usr/share/kodi/addons/skin.confluence/ /storage/.kodi/addons/

With the copy in place, when you reboot Kodi it will automatically use the new version in place of the old due to Kodi’s theme directory hierarchy. No other changes are required for this to happen.

Remove unnecessary Power Menu buttons

It would be nice to remove the Power off System option from the power menu – as it shuts the NUC down and I can’t turn it back on with my remote. Open /storage/.kodi/addons/skin.confluence/720p/DialogButtonMenu.xml and make the following changes:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<control type="button" id="3">
	<description>Shutdown button</description>
	<width>340</width>
	<height>40</height>
	<textcolor>grey2</textcolor>
	<focusedcolor>white</focusedcolor>
	<align>center</align>
	<textwidth>290</textwidth>
	<texturefocus border="25,5,25,5">ShutdownButtonFocus.png</texturefocus>
	<texturenofocus border="25,5,25,5">ShutdownButtonNoFocus.png</texturenofocus>
	<onclick>Powerdown()</onclick>
	<!-- <visible>System.CanPowerDown</visible> -->	<visible>no</visible>	<pulseonselect>no</pulseonselect>
	<font>font13</font>
	<label>13016</label>
</control>
<control type="button" id="4">
	<description>Custom Shutdown Timer</description>
	<width>340</width>
	<height>40</height>
	<textcolor>grey2</textcolor>
	<focusedcolor>white</focusedcolor>
	<align>center</align>
	<textwidth>290</textwidth>
	<texturefocus border="25,5,25,5">ShutdownButtonFocus.png</texturefocus>
	<texturenofocus border="25,5,25,5">ShutdownButtonNoFocus.png</texturenofocus>
	<onclick>AlarmClock(shutdowntimer,Shutdown())</onclick>
	<pulseonselect>no</pulseonselect>
	<font>font13</font>
	<label>20150</label>
	<!-- <visible>!System.HasAlarm(shutdowntimer)</visible>	<visible>System.CanPowerDown | System.CanSuspend | System.CanHibernate</visible> -->	<visible>no</visible></control>

Thanks to Gerhard Burger on AskUbuntu for his post on how to do this.

Bonus: Point Videos and Music straight to their Files folders

This is something that has annoyed me to no end. When I click on Videos or Music on the home screen, I always just want to go to Files but Confluence insists on having a useless intermediary screen. Below we’ll fix that. Open /storage/.kodi/addons/skin.confluence/720p/Home.xml and make the following changes:

1
2
3
4
5
6
7
<!-- around line 930 change -->
<!-- <onclick condition="StringCompare(Window.Property(VideosDirectLink),True)">ActivateWindow(Videos)</onclick> -->
<onclick condition="StringCompare(Window.Property(VideosDirectLink),True)">ActivateWindow(Videos,Files,return)</onclick> 
<!-- around line 953 change -->
<!-- <onclick>ActivateWindow(Music)</onclick> -->
<onclick>ActivateWindow(Music,Files,return)</onclick>

Thanks to user eliaslear on the OpenELEC forums for his post detailing how to do this.