Friday, November 21, 2014

Auto-start XBMC on demand from your remote

A really simple script that starts XBMC automagically when a remote tries to access it:
/home/tv/xbmc-on-demand.sh:
#!/bin/sh
while true; do
  echo Starting XBMC... | nc -vl 8080
  xbmc
  sleep 7
done
(Don't forget to chmod +x xbmc-on-demand.sh)

The sleep is there to prevent XBMC from restarting right after quitting from the remote, giving you a few seconds to shut down the remote itself.

Run this automatically within your X session (XFCE being my favorite), and whenever a connection is attempted to TCP port 8080 (default for XBMC), xbmc will start.

This is my ~/.config/autostart/xbmc-on-demand.desktop to have it running in background on every Freedesktop (XFCE, GNOME, KDE, etc) login:
/home/tv/.config/autostart/xbmc-on-demand.desktop:
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=xbmc
Comment=
Exec=/home/tv/xbmc-on-demand.sh
StartupNotify=false
Terminal=false
Hidden=false


I use it with "Music Pump XBMC Remote" for Android, the best and probably the lightest.