-
Notifications
You must be signed in to change notification settings - Fork 85
/
bt_pa_config.sh
executable file
·200 lines (170 loc) · 5.11 KB
/
bt_pa_config.sh
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
#The bluetooth device can appear as a number of things.
#Change the line '+ Class = 0x200414' below to one of the following classes;
# 0x200418 - Headphones
# 0x200414 - Loudspeaker (default)
# 0x200420 - Car Audio
# 0x200434 - Car audio, Loudspeaker
# 0x200438 - Car Audio, Headphones
#
# All of the above classes show the headphone icon on iOS when connected.
# If you wish to not have that icon then use one of the following;
# 0x20041C - Headphones, Portable Audio / Portable Audio
# 0x20043C - Headphones, Portable Audio, Car audio / Portable Audio, Car audio
if [ -z "$BluetoothName" ]
then
read -p "Bluetooth device name: " BluetoothName
fi
if [ -z "$exc" ]
then
source functions.sh
source dependencies.sh
fi
exc sudo cp usr/local/bin/volume-watcher.py /usr/local/bin/volume-watcher.py
exc sudo chmod +x /usr/local/bin/volume-watcher.py
exc sudo cp lib/systemd/system/volume-watcher.service /lib/systemd/system/volume-watcher.service
exc sudo systemctl enable volume-watcher
exc cd `dirname $0`
sudo echo "PRETTY_HOSTNAME=$BluetoothName" >> /tmp/machine-info
exc tst sudo cp /tmp/machine-info /etc
save_original /etc/init.d/pulseaudio
exc sudo cp init.d/pulseaudio /etc/init.d/pulseaudio
exc sudo chmod +x /etc/init.d/pulseaudio
exc sudo update-rc.d pulseaudio defaults
save_original /etc/init.d/bluetooth
exc sudo cp init.d/bluetooth /etc/init.d/bluetooth
exc sudo chmod +x /etc/init.d/bluetooth
exc sudo update-rc.d bluetooth defaults
save_original /etc/init.d/bluetooth-agent
if [ "$VOL_USER" = "\"arm\"" ]
then
exc sudo cp init.d/bluetooth-agent-vol /etc/init.d/bluetooth-agent
else
exc sudo cp init.d/bluetooth-agent /etc/init.d/bluetooth-agent
fi
exc sudo chmod +x /etc/init.d/bluetooth-agent
exc sudo update-rc.d bluetooth-agent defaults
exc sudo cp usr/local/bin/bluez-udev /usr/local/bin
exc sudo chmod 755 /usr/local/bin/bluez-udev
exc sudo cp usr/local/bin/simple-agent.autotrust /usr/local/bin
exc sudo chmod 755 /usr/local/bin/simple-agent.autotrust
exc sudo cp usr/local/bin/say.sh /usr/local/bin
exc sudo chmod 755 /usr/local/bin/say.sh
exc sudo cp usr/local/bin/bluezutils.py /usr/local/bin
if [ -d "/etc/pulse" ]
then
PA_FILES=`ls /etc/pulse`
for _file in ${PA_FILES[@]}; do
if [ -e $_file ]; then
if [ -d $_file ]; then
continue
else
save_original $_file
fi
fi
done
else
exc sudo mkdir /etc/pulse
fi
exc sudo cp etc/pulse/daemon.conf /etc/pulse/daemon.conf
save_original /boot/config.txt
exc cat << EOT | sudo tee -a /boot/config.txt
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
audio_pwm_mode=2
EOT
if [ -f /etc/udev/rules.d/99-com.rules ]; then
save_original /etc/udev/rules.d/99-com.rules
exc sudo patch /etc/udev/rules.d/99-com.rules << EOT
***************
*** 1 ****
--- 1,2 ----
SUBSYSTEM=="input", GROUP="input", MODE="0660"
+ KERNEL=="input[0-9]*", RUN+="/usr/local/bin/bluez-udev"
EOT
else
save_original /etc/udev/rules.d/99-com.rules
exc sudo touch /etc/udev/rules.d/99-com.rules
exc sudo chmod 666 /etc/udev/rules.d/99-com.rules
save_original /etc/udev/rules.d/99-input.rules
exc cat << EOT | sudo tee -a /etc/udev/rules.d/99-input.rules
SUBSYSTEM=="input", GROUP="input", MODE="0660"
KERNEL=="input[0-9]*", RUN+="/usr/local/bin/bluez-udev"
EOT
fi
exc sudo chmod 644 /etc/udev/rules.d/99-com.rules
save_original /etc/bluetooth/main.conf
exc sudo patch /etc/bluetooth/main.conf << EOT
***************
*** 7,8 ****
--- 7,9 ----
#Name = %h-%d
+ Name = ${BT_NAME}
***************
*** 11,12 ****
--- 12,14 ----
#Class = 0x000100
+ Class = 0x200414
***************
*** 15,17 ****
# 0 = disable timer, i.e. stay discoverable forever
! #DiscoverableTimeout = 0
--- 17,19 ----
# 0 = disable timer, i.e. stay discoverable forever
! DiscoverableTimeout = 0
EOT
save_original /etc/pulse/system.pa
exc sudo patch /etc/pulse/system.pa << EOT
***************
*** 23,25 ****
.ifexists module-udev-detect.so
! load-module module-udev-detect
.else
--- 23,26 ----
.ifexists module-udev-detect.so
! #load-module module-udev-detect
! load-module module-udev-detect tsched=0
.else
***************
*** 57 ****
--- 58,63 ----
load-module module-position-event-sounds
+
+ ### Automatically load driver modules for Bluetooth hardware
+ .ifexists module-bluetooth-discover.so
+ load-module module-bluetooth-discover
+ .endif
EOT
#sudo service bluetooth start &
#sudo service pulseaudio start &
#sudo service bluetooth-agent start &
# BT FIX
exc remove_dir /etc/pulsebackup
exc sudo mkdir /etc/pulsebackup
exc sudo cp /etc/pulse/* /etc/pulsebackup/
exc cd ~
exc remove_dir pulseaudio
exc git clone --branch v6.0 https://github.com/pulseaudio/pulseaudio
exc cd ~
exc remove_dir json-c
exc git clone https://github.com/json-c/json-c.git
exc cd json-c
exc sh autogen.sh
exc ./configure
exc make
exc sudo make install
exc cd ~
exc remove_dir libsndfile
exc git clone git://github.com/erikd/libsndfile.git
exc cd libsndfile
exc ./autogen.sh
exc ./configure --enable-werror
exc make
exc sudo make install
exc cd ~
exc cd pulseaudio
exc sudo ./bootstrap.sh
exc sudo make
exc sudo make install
exc sudo ldconfig
exc sudo cp /etc/pulsebackup/* /etc/pulse