[Linux] Starting XBMC using the remote via lirc
#1
Star 
The following is how I start XBMC using the remote on a non-dedicated "normal" computer from the Gnome desktop. The launcher script might seem a little obscure, but Works For Me ™.

Biggest problems were that lirc sends duplicate events somehow (and thus the launcher script protects itself against it). Also all lirc events handled while XBMC is running seem to get stacked up and replayed as soon as you quit XBMC — effectively starting XBMC again right away. This is also handled, by ignoring these events while XBMC is running.

Finally, the script sets the master audio volume to 100%, so the XBMC volume control can use the full volume range (don't know if that is needed in every setup).

First you have to create the launcher script, in " ~/etc/launch-xbmc" (or another path of your choice):
Code:
#! /bin/bash
pid=$(ps auxw | grep $0 | grep -v grep | tr -s ' ' | head -n1 | cut -f2 -d' ')
stamp="$(date '+%Y-%m-%d %H:%M:%S,%N')"
now="$(date '+%s')"

if test $pid != $$; then
    echo "$stamp Ignoring dupe start (pid=$$; winner=$pid)" >>/tmp/xbmc-launcher.log
elif test -z "$(pidof /usr/lib/xbmc/xbmc.bin)"; then
    echo "$stamp Starting XBMC" >>/tmp/xbmc-launcher.log
    amixer sset Master,0 100%
    xbmc &
else
    echo "$stamp XBMC already running" >>/tmp/xbmc-launcher.log
fi
sleep 0.05
Make it executable, and then add it to your "~/.lircrc" as follows:
Code:
begin
    prog = irexec
    remote = *
    button = Home
    repeat = 0
    config = ~/etc/launch-xbmc
end
Save it, and press the "Home" button on your remote...
Reply
#2
The script didn't work for me, so I rewrote it a little. It now only checks if xbmc or xbmc.bin are running.
Also, I set the DISPLAY variable, because I'm using /etc/lirc/lircrc and not ~/.lircrc.

Code:
#!/bin/bash
stamp="$(date '+%Y-%m-%d %H:%M:%S,%N')"

if [ ! -z "$(pidof /usr/bin/xbmc)" ]; then
    echo "$stamp XBMC already running (/usr/bin/xbmc)" >> /tmp/xbmc-launcher.log
    exit 0
fi

if [ ! -z "$(pidof /usr/lib/xbmc/xbmc.bin)" ]; then
    echo "$stamp XBMC already running (/usr/lib/xbmc/xbmc.bin)" >> /tmp/xbmc-launcher.log
    exit 0
fi

echo "$stamp Starting XBMC" >> /tmp/xbmc-launcher.log
amixer sset Master,0 100%
DISPLAY=:0 xbmc &
Fanless Linux HTPC/NAS: Streacom FC10, ASUS P8H77-M PRO, i3-3225, Corsair LP White DDR3-1600, picoPSU-150-XT, 1x SSD 840, 2x HDD WD Red 3TB
Stats: 29W idle, 55W load, CPU 38-43°C idle, CPU 55-60°C load, HDD 42-43°C idle, HDD 47°C load

Reply

Logout Mark Read Team Forum Stats Members Help
[Linux] Starting XBMC using the remote via lirc0