summaryrefslogtreecommitdiff
path: root/extra/remote-event.sh
blob: c059e5556af03fbe8987f6a9ed10d87c3801e84f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh

# x-vdr (Installations-Skript fuer einen VDR mit Debian als Basis)
# von Marc Wernecke - www.zulu-entertainment.de
# 25.04.2008

RemoteConf="/var/lib/vdr/remote.conf"
VdrConf="/etc/default/vdr"
XvdrConf="/usr/local/src/x-vdr/setup.conf"

if [ -r "$VdrConf" -a -w "$VdrConf" ]; then
  . $VdrConf
  [ -f "$VDRCONFDIR/remote.conf" ] && RemoteConf="$VDRCONFDIR/remote.conf"
fi

[ -w "$RemoteConf" ] || exit 1

RemoteEvent=`grep -m1 "remote-event" $RemoteConf | cut -d "." -f1`
[ -n "$RemoteEvent" ] || exit 2

DeviceNr=`dmesg | grep -m1 "DVB on-card IR receiver" | tr "/" "\n" | grep input | grep [0-9] | cut -c6`
[ -n "$DeviceNr" ] || exit 3

if [ "$RemoteEvent" != "remote-event${DeviceNr}" ]; then
  sed -i $RemoteConf -e s/$RemoteEvent/remote-event${DeviceNr}/g
  echo "Changing Remote-Device in $RemoteConf from $RemoteEvent to remote-event${DeviceNr}"
else
  echo "Remote-Device in $RemoteConf is $RemoteEvent"
fi

if [ -w "$VdrConf" ]; then
  if [ -n "$remote_event" ]; then
    DeviceNrOld=`echo "$remote_event" | tr "/" "\n" | grep [0-9] | cut -c6`
    if [ "$DeviceNrOld" != "$DeviceNr" ]; then
      sed -i $VdrConf -e s?remote_event=\"/dev/input/event${DeviceNrOld}\"?remote_event=\"/dev/input/event${DeviceNr}\"?g
      echo "Changing Remote-Device in $VdrConf from $remote_event to /dev/input/event${DeviceNr}"
    fi
  fi
fi

if [ -r "$XvdrConf" -a -w "$XvdrConf" ]; then
  . $XvdrConf
  if [ -n "$remote_event" ]; then
    DeviceNrOld=`echo "$remote_event" | tr "/" "\n" | grep [0-9] | cut -c6`
    if [ "$DeviceNrOld" != "$DeviceNr" ]; then
      sed -i $XvdrConf -e s?remote_event=\"/dev/input/event${DeviceNrOld}\"?remote_event=\"/dev/input/event${DeviceNr}\"?g
      echo "Changing Remote-Device in $XvdrConf from $remote_event to /dev/input/event${DeviceNr}"
    fi
  fi
fi

exit 0