summaryrefslogtreecommitdiff
blob: db275e6e7c449318b705a2a5e7abe1ddf76ebcb9 (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
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

depend() {
	need bluetooth alsasound
}

checkconfig() {
	# check that the configuration file has been configured.
	if [ -z "$BDADDR" ]; then
		eerror "You should setup BDADDR in /etc/conf.d/headset."
		return 1
	fi	

	# define BTSCO in /etc/conf.d/headset to be btsco or btsco2
	# defaults to btsco
	if [ -z "$BTSCO" ]; then
		BTSCO=btsco
	fi
	
	if ! [ -d /sys/module/snd_bt_sco ]; then
		ebegin "Loading bluetooth-alsa kernel module (snd_bt_sco)."
			/sbin/modprobe snd-bt-sco
		eend $? || return 1
	fi
}

start() {
	checkconfig || return 1

	ebegin "Connecting to headset"
        	start-stop-daemon --start \
		--make-pidfile --pidfile /var/run/$BTSCO \
		--background --exec /usr/bin/$BTSCO -- $BDADDR
		sleep 1
		ps -C $BTSCO >/dev/null
	eend $?
}

stop() {
        ebegin "Stopping $BTSCO daemon"
		start-stop-daemon --stop --quiet --pidfile /var/run/$BTSCO
	eend ${?}

}