Archive:Create a resume script

From Official Kodi Wiki
Jump to: navigation, search
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.

This guide assumes that you have performed all steps outlined in one of the articles listed here HOW-TO:Install_Kodi_for_Linux and here HOW-TO:Set_up_LIRC. This guide assumes that your remote works well upon startup. If it does not, then do not proceed with this article.

You will also need a SFTP client and a terminal emulator like WinSCP and Putty.

You will need root access for the following commands.

1 Setting up the basics

This section discusses installation and use of curl

1.1 Installing curl

  • Log into a terminal as root
  • Execute the following command to get a program which will allow you to turn on and off XBMC's remote monitoring function
apt-get install curl

1.2 Using Curl

  • Ensure XBMC's event server is enabled. XBMC-Settings-Network-Event Server-Enable event server

The following command will disable XBMC's ability to turn your remote's commands into usable input.

curl ""

The following command will enable XBMC's ability to turn your remote's commands into usable input.

curl ""

The following command will stop and then restart XBMC's ability to turn your remote's commands into usable input.

curl ""

2 Designing your resume script

This section discusses creating a basic lirc resume script. You will now go through each one of the sections and design your custom restart script. It is recommended that you create a wiki article like this one, Snapstream Firefly when you are finished. When you add to the wiki, it is documented so people who are not as good with scripting may follow behind your work.

2.1 Create your basic script outline

  • Open a notepad so that you can keep notes for your resume script
  • Copy the following into your notepad

# This script uses curl. Install curl using the following command from your terminal apt-get install curl
# This script will restart (ADD YOUR DEVICE NAME HERE WHEN FINISHED), Lirc, and XBMC upon resume.
case "$1" in 
		curl ""

		/etc/init.d/lirc restart 
		curl "" 
		echo "lirc resume script completed!!!" >>/tmp/script.log

This is the basic resume script outline. The two blank lines under curl "" will be for restarting your drivers.

2.2 checking remote output

  • put the computer in standby
  • resume from standby
  • From your terminal copy and paste the following to verify if your remote is working.
curl ""
/etc/init.d/lirc restart
curl "
  • Press a few buttons on your remote
  • press ctrl + C to exit irw

If your remote works, then skip to the creating a resume file section.

3 Finding the offending device

This section will cover locating the driver and restarting. The computer should be in a resumed state after completion of standby.

3.1 Ensuring physical device connectivity after standby

  • From your terminal type the following to verify your system is recognizing your remote's receiver
  • Search for your remote's physical device


(T: XBMCLive)[email protected]:~# lsusb
Bus 001 Device 003: ID 0bda:0151 Realtek Semiconductor Corp. Mass Stroage Device 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 0bc7:0008 X10 Wireless Technology, Inc. Wireless Transceiver (ACPI-compliant)
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
(T: XBMCLive)[email protected]:~#

08 X10 Wireless Technology, Inc. Wireless Transceiver (ACPI-compliant) is the remote device. You can verify this by unplugging the device and running lsusb again

  • If you cannot find your device, add the following to your notepad under the xbmc.stop command
/etc/init.d/udev restart
  • If you unplugged your remote receiver, you will need to put the computer back into suspend mode and resume again to recreate the fault condition

3.2 Locating and restarting drivers

  • List all lirc devices
sudo modprobe -l |grep lirc
  • Search for the driver which controls the physical device


(T: XBMCLive)[email protected]:~# sudo modprobe -l |grep lirc

in this case lirc_atiusb happens to be the driver

  • remove the binding of lirc to xbmc
curl ""
  • systematically restart drivers until your remote works in irw
rmmod lirc_atiusb
modprobe lirc_atiusb
/etc/init.d/lirc restart
  • press buttons on the remote to verify proper operation
  • stop irw with ctrl + C and try the next driver in the grep lirc list


(T: XBMCLive)[email protected]:~# curl ""
li OK /html
(T: XBMCLive)[email protected]:~# rmmod lirc_atiusb
(T: XBMCLive)[email protected]:~# modprobe lirc_atiusb
(T: XBMCLive)[email protected]:~# /etc/init.d/lirc restart
 * Stopping remote control daemon(s): LIRC                               [ OK ]
 * Loading LIRC modules                                                  [ OK ]
 * Starting remote control daemon(s) : LIRC                              [ OK ]
(T: XBMCLive)[email protected]:~# irw
000000146f9a0000 00 up Snapstream
000000146f9a0000 01 up Snapstream
  • Once you have determined which driver works, add that driver to your notepad
  • Change your notepad to reflect the proper driver in the notes at the top.



# This script uses curl. Install curl using the following command from your terminal apt-get install curl
# This script will restart ATIUSB, Lirc, and XBMC upon resume.

case "$1" in  
 		curl " /xbmcHttp?command=ExecBuilt&Inparameter=LIRC.Stop"
		rmmod lirc_atiusb
		modprobe lirc_atiusb
		/etc/init.d/lirc restart 
		irw & sleep 1; killall irw
		curl " parameter=LIRC.Start" 
		echo "lirc resume script completed!!!" >>/tmp/script.log

4 Creating a resume file

This section discusses creating your resume script after you have collected the required data.

4.1 Add your script to sleep.d

  • Using your SFTP client, create a file called /etc/pm/sleep.d/
  • add the contents of your notepad into /etc/pm/sleep.d/
  • make it executable
chmod +x /etc/pm/sleep.d/

You are now done.