Tuesday, 13 July 2010

Creating a button to restart XBMC

After spending many hours on this, XBMC being wiped and starting again at least 3 times without ever remembering what I did last time I think it's finally time to share how I did this so it is written and I never forget.


First we update the sources and download the package which allows running of scripts from a remote button (lirc-x).

sudo apt-get update
sudo apt-get install lirc-x


Next we ensure that this programme (irexec) runs as a daemon (in the background) as soon as we login to gnome by adding it to the .bash_login script


nano .bash_login


add the following code and save

irexec -d

next we make a file contaning the settings for which button and what to with it. I like to use the red button from the MSE remote to do this if you would like to use any other button just change 'red' below to the name of the button you want to choose (for non MSE remotes I have never used the so not sure if this will work, please research elsewhere)

nano .lircrc

add the following code and save

begin
prog = irexec
button = Red
config = ~/restartXBMC.sh
end


We have now said every time the red button is pressed to run the script restartXBMC.sh. Now we have to make this script.

nano restartXBMC.sh

add the following code and save

#!/bin/bash

ps aux|grep -i justcop |grep -v grep|grep -i xbmc.bin|awk '{print $2}'|xargs kill -9

sleep 2

xinit /usr/bin/xbmc
exit


The first line kills XBMC and then waits 2 seconds. The last line starts it back up again

Next we must make the script executable

chmod +x ~/restartXBMC.sh

All done!

No comments:

Post a Comment