Monday, June 14, 2010

Restarting XBMC via remote

I have this problem where XBMC can chew up to ~30% of a CPU. So when I'm doing CPU intensive things (mainly remotely) I like to kill XBMC. However when my wife turns on the TV, there's no XBMC for her to use. Rather than have complaints directed my way, I came up with a simple script that allows XBMC to be restarted when the power button on the remote is pressed. As mentioned previously my HTPC autologins on startup. Now instead of starting X, it runs a script which contains:

while [ 1 ] ; do
# starts X with required parameters

# poll for button press
irw | grep -q "Power mceusb" && killall irw

irw allows you to read off the socket that the remote is connected to. So the script greps for the string that indicates the power button is pressed, kills irw and restarts XBMC.

The nice bit is that this script uses ~0.2% of CPU :D.

No comments:

Post a Comment