summaryrefslogtreecommitdiff
blob: f7d3c52eb09bfc53def8833285b340c40043579b (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
# plugin-startup-skript for powermate-plugin
# $Id$

# try to autodetect device for powermate

detect_powermate() {
	POWERMATE_DEVICE=""

	local devfile
	local base
	local sysfile
	local linkdest

	for devfile in /dev/input/event*; do
		# check if devile is device
		[ -c "${devfile}" ] || continue

		# and for corresponding sysfs-entry
		base=${devfile/\/dev\/input\//}
		sysfile=/sys/class/input/${base}/device/driver
		[ -L "${sysfile}" ] || continue

		# if driver-link contains powermate
		linkdest=$(readlink ${sysfile})
		[ "${linkdest}" != "${linkdest#*powermate}" ] || continue

		# the we are done
		POWERMATE_DEVICE="${devfile}"
		break
	done
}

plugin_pre_vdr_start() {
	if [ "${POWERMATE_DEVICE:-auto}" = "auto" ]; then
		detect_powermate
	fi

	if [ -c "${POWERMATE_DEVICE}" ]; then
		chown vdr:vdr "${POWERMATE_DEVICE}"
		add_plugin_param "--device=${POWERMATE_DEVICE}"
	else
		ewarn "No powermate-device found."
	fi
}