@dotpi/tools 1.4.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTES.md +41 -1
- package/README.md +3 -13
- package/dotpi_root/bin/dotpi +1 -0
- package/dotpi_root/bin/dotpi_prepare_sd_card +34 -22
- package/dotpi_root/bin/dotpi_prepare_system +108 -68
- package/dotpi_root/bin/package.json +6 -0
- package/dotpi_root/{share/dotpi_avahi_monitor → dist/@dotpi/avahi_monitor}/dotpi_avahi_monitor.service +1 -5
- package/dotpi_root/dist/@dotpi/avahi_monitor/dotpi_install +21 -0
- package/dotpi_root/dist/@dotpi/avahi_monitor/dotpi_uninstall +17 -0
- package/dotpi_root/dist/@dotpi/avahi_monitor/package.json +10 -0
- package/dotpi_root/dist/@dotpi/javascript/bash.js +103 -0
- package/dotpi_root/dist/@dotpi/javascript/echo.js +13 -0
- package/dotpi_root/dist/@dotpi/javascript/filesystem.js +25 -0
- package/dotpi_root/dist/@dotpi/javascript/package.json +12 -0
- package/dotpi_root/dist/@dotpi/javascript/service.js +49 -0
- package/dotpi_root/dist/@dotpi/javascript/system.js +36 -0
- package/dotpi_root/dist/@dotpi/javascript/template.js +13 -0
- package/dotpi_root/dist/@dotpi/javascript/user.js +32 -0
- package/dotpi_root/dist/@dotpi/module/LICENSE +28 -0
- package/dotpi_root/dist/@dotpi/module/bin/dotpi_module +13 -0
- package/dotpi_root/dist/@dotpi/module/dotpi_install +52 -0
- package/dotpi_root/dist/@dotpi/module/dotpi_uninstall +50 -0
- package/dotpi_root/dist/@dotpi/module/package.json +22 -0
- package/dotpi_root/dist/@dotpi/module/src/configuration.js +43 -0
- package/dotpi_root/dist/@dotpi/module/src/createConfig.js +108 -0
- package/dotpi_root/dist/@dotpi/module/src/definition.js +7 -0
- package/dotpi_root/dist/@dotpi/module/src/index.js +0 -0
- package/dotpi_root/dist/@dotpi/module/src/install.js +145 -0
- package/dotpi_root/dist/@dotpi/module/src/uninstall.js +180 -0
- package/dotpi_root/etc/dotpi_environment_default.bash +16 -0
- package/dotpi_root/etc/dotpi_init.d/.gitkeep +0 -0
- package/dotpi_root/etc/dotpi_modules.json +8 -0
- package/dotpi_root/lib/package.json +6 -0
- package/dotpi_root/share/dotpi_audio_bluetooth/dotpi_audio_pipewire_relink +7 -6
- package/dotpi_root/share/dotpi_audio_bluetooth/package.json +6 -0
- package/dotpi_root/share/dotpi_functions/dotpi_functions_audio_device.bash +12 -26
- package/dotpi_root/share/dotpi_functions/dotpi_functions_configuration.bash +2 -2
- package/dotpi_root/share/dotpi_functions/dotpi_functions_service.bash +6 -2
- package/dotpi_root/share/dotpi_functions/dotpi_functions_system.bash +11 -0
- package/dotpi_root/share/dotpi_functions/dotpi_functions_user.bash +28 -0
- package/dotpi_root/share/dotpi_functions.bash +4 -4
- package/dotpi_root/share/dotpi_init.bash +7 -1
- package/dotpi_root/share/dotpi_pipewire/bin/dotpi_pipewire_relink +7 -6
- package/dotpi_root/share/dotpi_pipewire/dotpi_install +1 -1
- package/dotpi_root/share/dotpi_pipewire/package.json +9 -0
- package/dotpi_root/share/limits/zzz_dotpi_audio.conf +2 -6
- package/dotpi_root/share/wireplumber/wireplumber.conf.d/dotpi-wireplumber-config.conf +8 -0
- package/lerna.json +4 -0
- package/package.json +12 -2
- package/projects/led-test/.dotpi +3 -0
- package/projects/led-test/README.md +16 -0
- package/projects/led-test/dotpi_project.bash +29 -0
- package/projects/qsddsqsd/.dotpi +3 -0
- package/projects/qsddsqsd/README.md +16 -0
- package/projects/qsddsqsd/dotpi_project.bash +29 -0
- package/src/constants.js +4 -4
- package/src/create-project.js +124 -56
- package/src/templates/dotpi_project.bash +5 -7
- package/src/utils.js +2 -2
- package/test/create-project.test.js +0 -1
- package/PIPEWIRE.md +0 -280
- package/dotpi_root/bin/.editorbackup/dotpi_firstrun.bash~ +0 -149
- package/dotpi_root/bin/.editorbackup/dotpi_firstrun~ +0 -177
- package/dotpi_root/bin/.editorbackup/dotpi_prepare_sd_card.bash~ +0 -425
- package/dotpi_root/bin/.editorbackup/dotpi_prepare_sd_card~ +0 -620
- package/dotpi_root/bin/.editorbackup/dotpi_prepare_system.bash~ +0 -82
- package/dotpi_root/bin/.editorbackup/dotpi_prepare_system~ +0 -100
- package/dotpi_root/bin/.editorbackup/dotpi~ +0 -61
- package/dotpi_root/bin/.editorbackup/prepare_sd_card.bash~ +0 -252
- package/dotpi_root/etc/.editorbackup/dotpi_environment_default.bash~ +0 -49
- package/dotpi_root/etc/.editorbackup/dotpi_environment_instance.bash~ +0 -1
- package/dotpi_root/etc/.editorbackup/dotpi_environment_project.bash~ +0 -33
- package/dotpi_root/etc/.editorbackup/dotpi_tarignore~ +0 -4
- package/dotpi_root/share/.editorbackup/coucou~ +0 -1
- package/dotpi_root/share/.editorbackup/dotpi_environment.bash~ +0 -9
- package/dotpi_root/share/.editorbackup/dotpi_functions.bash~ +0 -11
- package/dotpi_root/share/.editorbackup/dotpi_functions_configuration.bash~ +0 -420
- package/dotpi_root/share/.editorbackup/dotpi_functions_connection.bash~ +0 -358
- package/dotpi_root/share/.editorbackup/dotpi_init.bash~ +0 -18
- package/dotpi_root/share/dotpi_audio_alsa/dotpi_audio_alsa.service +0 -15
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth.service~ +0 -24
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_command~ +0 -80
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_start_command~ +0 -26
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_stop_command~ +0 -30
- package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_bluetooth_audio.service~ +0 -21
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_audio_bluetooth.bash~ +0 -256
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_audio_device.bash~ +0 -287
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_bluetooth_audio.bash~ +0 -7
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_configuration.bash~ +0 -428
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_connection.bash~ +0 -194
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_daemon.bash~ +0 -26
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_soundcard.bash~ +0 -287
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_soundcards.bash~ +0 -12
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_system.bash~ +0 -158
- package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_utils.bash~ +0 -152
- package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_bluetooth.bash~ +0 -20
- package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_command~ +0 -17
- package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_headphones.bash~ +0 -20
- package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_hifiberry.bash~ +0 -16
- package/dotpi_root/share/jackd/.editorbackup/jackd.conf~ +0 -5
- package/dotpi_root/share/jackd/.editorbackup/jackd.service~ +0 -15
- package/dotpi_root/share/jackd/.editorbackup/jackd_headphones.conf~ +0 -5
- package/dotpi_root/share/jackd/dotpi_jack_simple_client.service +0 -23
- package/dotpi_root/share/jackd/dotpi_jackd_bluetooth.bash +0 -18
- package/dotpi_root/share/jackd/dotpi_jackd_command +0 -26
- package/dotpi_root/share/jackd/dotpi_jackd_headphones.bash +0 -21
- package/dotpi_root/share/jackd/dotpi_jackd_hifiberry.bash +0 -17
- package/dotpi_root/share/jackd/jackd.service +0 -22
- package/dotpi_root/share/wireplumber/.editorbackup/8zzz-dotpi-wireplumber-config.lua~ +0 -1
- package/projects/old/dev.bak/.editorbackup/dotpi_environment_instance.bash~ +0 -1
- package/projects/old/dev.bak/.editorbackup/dotpi_environment_project.bash~ +0 -33
- package/projects/old/dev.bak/.editorbackup/wpa_supplicant.conf~ +0 -37
- package/projects/old/dev.bak/dotpi_environment_instance.bash +0 -1
- package/projects/old/dev.bak/dotpi_environment_project.bash +0 -46
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/DOTPI-A114.nmconnection~ +0 -24
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/DOTPI.nmconnection~ +0 -24
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/Livebox-97C6_wifi_invite.nmconnection~ +0 -24
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/onze.nmconnection~ +0 -22
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/welcome.nmconnection~ +0 -23
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/DOTPI-A114.nmconnection +0 -23
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/DOTPI.nmconnection +0 -23
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/Livebox-97C6_wifi_invite.nmconnection +0 -24
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/onze.nmconnection +0 -24
- package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/welcome.nmconnection +0 -23
- package/projects/old/dev.bak/network/.editorbackup/DOTPI-A114.nmconnection~ +0 -24
- package/projects/old/dev.bak/network/.editorbackup/DOTPI.nmconnection~ +0 -24
- package/projects/old/dev.bak/network/.editorbackup/Livebox-97C6_wifi_invite.nmconnection~ +0 -24
- package/projects/old/dev.bak/network/.editorbackup/onze.nmconnection~ +0 -22
- package/projects/old/dev.bak/network/.editorbackup/welcome.nmconnection~ +0 -23
- package/projects/old/dev.bak/network/AccueilCie.nmconnection +0 -24
- package/projects/old/dev.bak/network/DOTPI-A114.nmconnection +0 -23
- package/projects/old/dev.bak/network/DOTPI.nmconnection +0 -23
- package/projects/old/dev.bak/network/Livebox-97C6_wifi_invite.nmconnection +0 -25
- package/projects/old/dev.bak/network/onze.nmconnection +0 -24
- package/projects/old/dev.bak/network/welcome.nmconnection +0 -23
- package/projects/old/dev.bak/network/wifi-access-point.nmconnection +0 -23
- package/projects/old/dev.bak/network/wifi-internet.nmconnection +0 -24
- package/projects/old/dev.bak/network/wifi-ircam-public.nmconnection +0 -24
- package/projects/old/dev.bak/network/wifi-local.nmconnection +0 -22
- package/projects/old/dev.bak/network/wifi-welcome.nmconnection +0 -24
- package/projects/old/dev.bak/wpa_supplicant.conf +0 -43
- package/projects/old/example-complete.bak/.editorbackup/dotpi_environment_instance.bash~ +0 -1
- package/projects/old/example-complete.bak/.editorbackup/dotpi_environment_project.bash~ +0 -26
- package/projects/old/example-complete.bak/.editorbackup/dotpi_project.bash~ +0 -21
- package/projects/old/example-complete.bak/.editorbackup/dotpi_tmp.bash~ +0 -3
- package/projects/old/example-complete.bak/.editorbackup/wpa_supplicant.conf~ +0 -37
- package/projects/old/example-complete.bak/configuration/.editorbackup/dotpi_project.bash~ +0 -21
- package/projects/old/example-complete.bak/configuration/dotpi_project.bash +0 -21
- package/projects/old/example-complete.bak/configuration/jackd/.editorbackup/dotpi_jackd.bash~ +0 -14
- package/projects/old/example-complete.bak/configuration/jackd/dotpi_jackd.bash +0 -14
- /package/dotpi_root/{share/dotpi_avahi_monitor → dist/@dotpi/avahi_monitor}/dotpi_avahi_monitor_command +0 -0
package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_audio_bluetooth.bash~
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
_dotpi_audio_bluetooth_controller='hci0'
|
|
4
|
-
|
|
5
|
-
dotpi_audio_bluetooth_destination_connect() (
|
|
6
|
-
destination_mac="$dotpi_audio_bluetooth_mac"
|
|
7
|
-
|
|
8
|
-
dotpi_echo_info "Starting bluetoothctl process"
|
|
9
|
-
status='init'
|
|
10
|
-
coproc btctl_process { bluetoothctl; }
|
|
11
|
-
|
|
12
|
-
while IFS= read -r output ; do
|
|
13
|
-
echo "$output" >&2
|
|
14
|
-
|
|
15
|
-
if [[ "$status" == 'init' ]]; then
|
|
16
|
-
dotpi_echo_info "Registering agent"
|
|
17
|
-
echo "default-agent" >&${btctl_process[1]}
|
|
18
|
-
echo "agent on" >&${btctl_process[1]}
|
|
19
|
-
|
|
20
|
-
dotpi_echo_info "Starting scan"
|
|
21
|
-
echo "scan on" >&${btctl_process[1]}
|
|
22
|
-
status='starting scan'
|
|
23
|
-
fi
|
|
24
|
-
|
|
25
|
-
if [[ "$status" == "starting scan" ]] \
|
|
26
|
-
&& [[ "$output" =~ "Discovery started" ]] ; then
|
|
27
|
-
dotpi_echo_info "Waiting for destination"
|
|
28
|
-
status='scanning'
|
|
29
|
-
fi
|
|
30
|
-
|
|
31
|
-
if [[ "$status" == "scanning" ]] \
|
|
32
|
-
&& [[ "$output" =~ Device.*"$destination_mac" ]] ; then
|
|
33
|
-
dotpi_echo_info "Destination discovered"
|
|
34
|
-
status='destination discovered'
|
|
35
|
-
fi
|
|
36
|
-
|
|
37
|
-
if [[ "$status" == 'destination discovered' ]] ; then
|
|
38
|
-
dotpi_echo_info "Pairing destination"
|
|
39
|
-
echo "pair ${destination_mac}" >&${btctl_process[1]}
|
|
40
|
-
status='pairing'
|
|
41
|
-
fi
|
|
42
|
-
|
|
43
|
-
if [[ "$status" == "pairing" ]] \
|
|
44
|
-
&& [[ "$output" =~ "Pairing successful" ]] ; then
|
|
45
|
-
dotpi_echo_info "Destination paired"
|
|
46
|
-
status='destination paired'
|
|
47
|
-
fi
|
|
48
|
-
|
|
49
|
-
if [[ "$status" == "pairing" ]] \
|
|
50
|
-
&& [[ "$output" =~ "Failed to pair" ]] ; then
|
|
51
|
-
dotpi_echo_error "Paring failed"
|
|
52
|
-
dotpi_echo_warning "Turn destination on, in discovery mode"
|
|
53
|
-
sleep 1
|
|
54
|
-
echo "pair ${destination_mac}" >&${btctl_process[1]}
|
|
55
|
-
status='pairing'
|
|
56
|
-
fi
|
|
57
|
-
|
|
58
|
-
if [[ "$status" == "destination paired" ]] ; then
|
|
59
|
-
dotpi_echo_info "Connecting destination"
|
|
60
|
-
echo "connect ${destination_mac}" >&${btctl_process[1]}
|
|
61
|
-
status='connecting'
|
|
62
|
-
fi
|
|
63
|
-
|
|
64
|
-
if [[ "$status" == "connecting" ]] \
|
|
65
|
-
&& [[ "$output" =~ "Connection successful" ]] ; then
|
|
66
|
-
dotpi_echo_info "Destination connected"
|
|
67
|
-
status='destination connected'
|
|
68
|
-
fi
|
|
69
|
-
|
|
70
|
-
if [[ "$status" == "destination connected" ]] ; then
|
|
71
|
-
dotpi_echo_info "Trusting destination"
|
|
72
|
-
echo "trust ${destination_mac}" >&${btctl_process[1]}
|
|
73
|
-
status='trusting'
|
|
74
|
-
fi
|
|
75
|
-
|
|
76
|
-
if [[ "$status" == "trusting" ]] \
|
|
77
|
-
&& [[ "$output" =~ "trust succeeded" ]] ; then
|
|
78
|
-
dotpi_echo_info "Destination trusted"
|
|
79
|
-
status='destination trusted'
|
|
80
|
-
fi
|
|
81
|
-
|
|
82
|
-
if [[ "$status" == "destination trusted" ]] ; then
|
|
83
|
-
dotpi_echo_info "Ending scan"
|
|
84
|
-
echo "scan off" >&${btctl_process[1]}
|
|
85
|
-
status='ending scan'
|
|
86
|
-
fi
|
|
87
|
-
|
|
88
|
-
if [[ "$status" == "ending scan" ]] \
|
|
89
|
-
&& [[ "$output" =~ "Discovery stopped" ]] ; then
|
|
90
|
-
dotpi_echo_info "Exiting"
|
|
91
|
-
status='exiting'
|
|
92
|
-
fi
|
|
93
|
-
|
|
94
|
-
if [[ "$status" == 'exiting' ]] ; then
|
|
95
|
-
echo "exit" >&${btctl_process[1]}
|
|
96
|
-
dotpi_echo_info "Done"
|
|
97
|
-
status='done'
|
|
98
|
-
break
|
|
99
|
-
fi
|
|
100
|
-
|
|
101
|
-
done <&${btctl_process[0]}
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
dotpi_audio_bluetooth_destination_disconnect() (
|
|
105
|
-
bluetoothctl -- remove "$dotpi_audio_bluetooth_mac"
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
_dotpi_audio_bluetooth_destination_start_ue() (
|
|
109
|
-
destination_mac="$dotpi_audio_bluetooth_mac"
|
|
110
|
-
destination_descriptor="${dotpi_audio_bluetooth_mac//:/_}"
|
|
111
|
-
|
|
112
|
-
trusted_mac="$(hciconfig "$_dotpi_audio_bluetooth_controller" \
|
|
113
|
-
| perl -ne 'if (m/BD Address:\s*([\w:]+).*$/i) { print "${1}\n"; }')"
|
|
114
|
-
|
|
115
|
-
coproc btctl_process { bluetoothctl; }
|
|
116
|
-
|
|
117
|
-
# test if already here
|
|
118
|
-
echo 'transport.list' >&${btctl_process[1]}
|
|
119
|
-
|
|
120
|
-
gatttool \
|
|
121
|
-
--adapter "$_dotpi_audio_bluetooth_controller" \
|
|
122
|
-
--device "${destination_mac}" \
|
|
123
|
-
--char-write-req \
|
|
124
|
-
--handle 0x0003 \
|
|
125
|
-
--value "${trusted_mac//:/}01"
|
|
126
|
-
|
|
127
|
-
while IFS= read -r output ; do
|
|
128
|
-
echo "$output" >&2
|
|
129
|
-
|
|
130
|
-
# Connected and transport volume available
|
|
131
|
-
if [[ "$output" =~ [CHG].*Transport.*/org/bluez/.*dev_"${destination_descriptor}".*Volume ]] \
|
|
132
|
-
|| [[ "$output" =~ ^Transport.*/org/bluez/.*dev_"${destination_descriptor}" ]] ; then
|
|
133
|
-
kill ${btctl_process_PID}
|
|
134
|
-
break
|
|
135
|
-
fi
|
|
136
|
-
done <&${btctl_process[0]}
|
|
137
|
-
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
dotpi_audio_bluetooth_destination_start() (
|
|
141
|
-
model_normalised="$(dotpi_audio_device_model_normalise "$dotpi_audio_device")"
|
|
142
|
-
|
|
143
|
-
case "$model_normalised" in
|
|
144
|
-
|
|
145
|
-
'ue boom 2'|'ue boom 3'|'ue megaboom 2'|'ue megaboom 3')
|
|
146
|
-
_dotpi_audio_bluetooth_destination_start_ue
|
|
147
|
-
;;
|
|
148
|
-
|
|
149
|
-
*)
|
|
150
|
-
dotpi_echo_error "Unable to start unknown model '${dotpi_audio_device}'"
|
|
151
|
-
return 1
|
|
152
|
-
;;
|
|
153
|
-
|
|
154
|
-
esac
|
|
155
|
-
|
|
156
|
-
dotpi_audio_bluetooth_destination_volume_init
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
_dotpi_audio_bluetooth_destination_stop_ue() (
|
|
161
|
-
destination_mac="$dotpi_audio_bluetooth_mac"
|
|
162
|
-
destination_descriptor="${dotpi_audio_bluetooth_mac//:/_}"
|
|
163
|
-
|
|
164
|
-
trusted_mac="$(hciconfig "$_dotpi_audio_bluetooth_controller" \
|
|
165
|
-
| perl -ne 'if (m/BD Address:\s*([\w:]+).*$/i) { print "${1}\n"; }')"
|
|
166
|
-
|
|
167
|
-
dotpi echo_info "Starting bluetoothctl monitor process"
|
|
168
|
-
coproc btctl_process { bluetoothctl; }
|
|
169
|
-
|
|
170
|
-
# will trigger a connection, even if destination if off, for write request (BLE)
|
|
171
|
-
# hence the [CHG] ... Connected: no
|
|
172
|
-
gatttool \
|
|
173
|
-
--adapter "$_dotpi_audio_bluetooth_controller" \
|
|
174
|
-
--device "${destination_mac}" \
|
|
175
|
-
--char-write-req \
|
|
176
|
-
--handle 0x0003 \
|
|
177
|
-
--value "${trusted_mac//:/}02"
|
|
178
|
-
|
|
179
|
-
while IFS= read -r output ; do
|
|
180
|
-
echo "$output" >&2
|
|
181
|
-
|
|
182
|
-
# destination disconnected
|
|
183
|
-
if [[ "$output" =~ [DEL].*Endpoint.*/org/bluez/.*dev_"${destination_descriptor}" ]] \
|
|
184
|
-
|| [[ "$output" =~ [CHG].*Device.*"$destination_mac".*Connected:.*no ]] ; then
|
|
185
|
-
|
|
186
|
-
kill ${btctl_process_PID}
|
|
187
|
-
break
|
|
188
|
-
fi
|
|
189
|
-
done <&${btctl_process[0]}
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
dotpi_audio_bluetooth_destination_stop() (
|
|
193
|
-
model_normalised="$(dotpi_audio_device_model_normalise "$dotpi_audio_device")"
|
|
194
|
-
|
|
195
|
-
case "$model_normalised" in
|
|
196
|
-
|
|
197
|
-
'ue boom 2'|'ue boom 3'|'ue megaboom 2'|'ue megaboom 3')
|
|
198
|
-
_dotpi_audio_bluetooth_destination_stop_ue
|
|
199
|
-
;;
|
|
200
|
-
|
|
201
|
-
*)
|
|
202
|
-
dotpi_echo_error "Unable to stop unknown model '${dotpi_audio_device}'"
|
|
203
|
-
return 1
|
|
204
|
-
;;
|
|
205
|
-
|
|
206
|
-
esac
|
|
207
|
-
)
|
|
208
|
-
|
|
209
|
-
dotpi_audio_bluetooth_destination_volume_set() (
|
|
210
|
-
destination_volume="$1"
|
|
211
|
-
destination_device="dev_${dotpi_audio_bluetooth_mac//:/_}"
|
|
212
|
-
destination_transport="$(bluetoothctl transport.list \
|
|
213
|
-
| perl -ne 'if(m/Transport\s+(\/*${destination_device}[^\s]+).*$/) { print "${1}\n"; }')"
|
|
214
|
-
|
|
215
|
-
if [[ -z "$destination_transport" ]] ; then
|
|
216
|
-
dotpi_echo_error "Failed to set volume: audio bluetooth device not found"
|
|
217
|
-
return 1
|
|
218
|
-
fi
|
|
219
|
-
|
|
220
|
-
bluetoothctl transport.volume "$destination_transport" "$destination_volume"
|
|
221
|
-
if (( $? != 0 )) ; then
|
|
222
|
-
dotpi_echo_error "Failed to set bluetooth destination volume"
|
|
223
|
-
return 1
|
|
224
|
-
else
|
|
225
|
-
dotpi_echo_info "Bluetooth destination volume set to ${destination_volume}"
|
|
226
|
-
fi
|
|
227
|
-
|
|
228
|
-
if [[ "$destination_volume" == "$dotpi_audio_volume" ]] ; then
|
|
229
|
-
# no change to write
|
|
230
|
-
return 0
|
|
231
|
-
fi
|
|
232
|
-
|
|
233
|
-
# comment setting in project
|
|
234
|
-
dotpi_configuration_comment --file "${DOTPI_ROOT}/etc/dotpi_environment_project.bash" \
|
|
235
|
-
--key dotpi_audio_volume
|
|
236
|
-
|
|
237
|
-
# escape double-quote for now, to quote when writing later
|
|
238
|
-
model_value="$(echo "$model" | dotpi_sed 's/"/\\"/g')"
|
|
239
|
-
|
|
240
|
-
# write changed setting in instance
|
|
241
|
-
dotpi_configuration_write --file "${DOTPI_ROOT}/etc/dotpi_environment_instance.bash" \
|
|
242
|
-
--key dotpi_audio_volume \
|
|
243
|
-
--value "$destination_volume"
|
|
244
|
-
|
|
245
|
-
)
|
|
246
|
-
|
|
247
|
-
dotpi_audio_bluetooth_destination_volume_init() (
|
|
248
|
-
if [[ -z "$dotpi_audio_volume" ]] ; then
|
|
249
|
-
dotpi_echo_warning "dotpi_audio_volume not set, keeping default volume"
|
|
250
|
-
return 0
|
|
251
|
-
fi
|
|
252
|
-
|
|
253
|
-
destination_volume="$dotpi_audio_volume"
|
|
254
|
-
dotpi_audio_bluetooth_destination_volume_set "$destination_volume"
|
|
255
|
-
)
|
|
256
|
-
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
_dotpi_audio_device_get_options() {
|
|
4
|
-
|
|
5
|
-
_echo_empty_option_error() {
|
|
6
|
-
dotpi_echo_error "$1 requires a non-empty option argument."
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
# From http://mywiki.wooledge.org/BashFAQ/035
|
|
10
|
-
|
|
11
|
-
while true ; do
|
|
12
|
-
case $1 in
|
|
13
|
-
|
|
14
|
-
-h|-\?|--help)
|
|
15
|
-
_dotpi_usage # Display a usage synopsis.
|
|
16
|
-
return 0
|
|
17
|
-
;;
|
|
18
|
-
|
|
19
|
-
-m|--model) # Takes an option argument; ensure it has been specified.
|
|
20
|
-
if [ -z "$2" ] ; then
|
|
21
|
-
_dotpi_usage
|
|
22
|
-
_echo_empty_option_error "$1"
|
|
23
|
-
return 1
|
|
24
|
-
else
|
|
25
|
-
model="$2"
|
|
26
|
-
shift
|
|
27
|
-
fi
|
|
28
|
-
;;
|
|
29
|
-
|
|
30
|
-
-c|--config) # Takes an option argument; ensure it has been specified.
|
|
31
|
-
if [ -z "$2" ] ; then
|
|
32
|
-
_dotpi_usage
|
|
33
|
-
_echo_empty_option_error "$1"
|
|
34
|
-
return 1
|
|
35
|
-
else
|
|
36
|
-
config_file="$2"
|
|
37
|
-
shift
|
|
38
|
-
fi
|
|
39
|
-
;;
|
|
40
|
-
|
|
41
|
-
--) # End of all options.
|
|
42
|
-
shift
|
|
43
|
-
break
|
|
44
|
-
;;
|
|
45
|
-
|
|
46
|
-
-?*) # Unknown
|
|
47
|
-
_dotpi_usage
|
|
48
|
-
dotpi_echo_error "Unknown option: $1"
|
|
49
|
-
return 1
|
|
50
|
-
;;
|
|
51
|
-
|
|
52
|
-
*) # Default case: No more options, so break out of the loop.
|
|
53
|
-
break
|
|
54
|
-
|
|
55
|
-
esac
|
|
56
|
-
|
|
57
|
-
shift
|
|
58
|
-
done
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
dotpi_audio_device_model_normalise() {
|
|
63
|
-
echo "$1" | tr '[:upper:]' '[:lower:]'
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
dotpi_audio_device_select() (
|
|
67
|
-
# sub-shell to keep everything local (functions and variables)
|
|
68
|
-
|
|
69
|
-
_dotpi_command="$(basename -- "${FUNCNAME[0]:-"$0"}")"
|
|
70
|
-
_dotpi_usage() {
|
|
71
|
-
echo "Usage: ${_dotpi_command} --model <model> --config <config_file_path>"
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
# Initialize all the option variables.
|
|
75
|
-
# This ensures we are not contaminated by variables from the environment.
|
|
76
|
-
model=
|
|
77
|
-
config_file=
|
|
78
|
-
|
|
79
|
-
if ! _dotpi_audio_device_get_options "${@}" ; then
|
|
80
|
-
return $?
|
|
81
|
-
fi
|
|
82
|
-
|
|
83
|
-
if [ -z "$model" ] ; then
|
|
84
|
-
_dotpi_usage
|
|
85
|
-
dotpi_echo_error "missing model option"
|
|
86
|
-
return 1
|
|
87
|
-
fi
|
|
88
|
-
|
|
89
|
-
if [ -z "$config_file" ] ; then
|
|
90
|
-
config_path="$(dotpi_system_get_bootfs_path)"
|
|
91
|
-
if [ -z "$config_path" ] ; then
|
|
92
|
-
dotpi_echo_error "Unable to get default system path for config file"
|
|
93
|
-
_dotpi_usage
|
|
94
|
-
return 1
|
|
95
|
-
fi
|
|
96
|
-
config_filename='config.txt'
|
|
97
|
-
config_file="${config_path}/${config_filename}"
|
|
98
|
-
dotpi_echo_warning "Using default config file ${config_file}"
|
|
99
|
-
fi
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if ! [ -w "$config_file" ] ; then
|
|
103
|
-
dotpi_echo_error "Unable to access config file ${config_file} for writing"
|
|
104
|
-
return 1
|
|
105
|
-
fi
|
|
106
|
-
|
|
107
|
-
# lowercase everything
|
|
108
|
-
model_normalised="$(dotpi_audio_device_model_normalise "$model")"
|
|
109
|
-
|
|
110
|
-
case "$model_normalised" in
|
|
111
|
-
|
|
112
|
-
# HiFiBerry
|
|
113
|
-
# Cf. https://www.hifiberry.com/docs/software/configuring-linux-3-18-x/
|
|
114
|
-
|
|
115
|
-
'hifiberry dac for raspberry pi 1'|'hifiberry dac+ light'|'hifiberry dac zero'|'hifiberry miniamp'|'hifiberry beocreate'|'hifiberry dac+ dsp'|'hifiberry dac+ rtc')
|
|
116
|
-
dtoverlay=hifiberry-dac
|
|
117
|
-
_dotpi_audio_device_select_hifiberry
|
|
118
|
-
;;
|
|
119
|
-
|
|
120
|
-
'hifiberry dac+ standard'|'hifiberry pro'|'hifiberry amp2')
|
|
121
|
-
dtoverlay=hifiberry-dacplus
|
|
122
|
-
_dotpi_audio_device_select_hifiberry
|
|
123
|
-
;;
|
|
124
|
-
|
|
125
|
-
'hifiberry dac2 hd')
|
|
126
|
-
dtoverlay=hifiberry-dacplushd
|
|
127
|
-
_dotpi_audio_device_select_hifiberry
|
|
128
|
-
;;
|
|
129
|
-
|
|
130
|
-
'hifiberry dac+ adc')
|
|
131
|
-
dtoverlay=hifiberry-dacplusadc
|
|
132
|
-
_dotpi_audio_device_select_hifiberry
|
|
133
|
-
;;
|
|
134
|
-
|
|
135
|
-
'hifiberry dac+ adc pro')
|
|
136
|
-
dtoverlay=hifiberry-dacplusadcpro
|
|
137
|
-
_dotpi_audio_device_select_hifiberry
|
|
138
|
-
;;
|
|
139
|
-
|
|
140
|
-
'hifiberry digi+')
|
|
141
|
-
dtoverlay=hifiberry-digi
|
|
142
|
-
_dotpi_audio_device_select_hifiberry
|
|
143
|
-
;;
|
|
144
|
-
|
|
145
|
-
'hifiberry digi+ pro')
|
|
146
|
-
dtoverlay=hifiberry-digi-pro
|
|
147
|
-
_dotpi_audio_device_select_hifiberry
|
|
148
|
-
;;
|
|
149
|
-
|
|
150
|
-
'hifiberry amp+')
|
|
151
|
-
dtoverlay=hifiberry-amp
|
|
152
|
-
_dotpi_audio_device_select_hifiberry
|
|
153
|
-
;;
|
|
154
|
-
|
|
155
|
-
'hifiberry amp3')
|
|
156
|
-
dtoverlay=hifiberry-amp3
|
|
157
|
-
_dotpi_audio_device_select_hifiberry
|
|
158
|
-
;;
|
|
159
|
-
|
|
160
|
-
headphones)
|
|
161
|
-
_dotpi_audio_device_select_headphones
|
|
162
|
-
;;
|
|
163
|
-
|
|
164
|
-
default)
|
|
165
|
-
dotpi_echo_warning "Not installing a specific audio device, keeping defaults"
|
|
166
|
-
;;
|
|
167
|
-
|
|
168
|
-
none)
|
|
169
|
-
_dotpi_audio_device_disable_all
|
|
170
|
-
;;
|
|
171
|
-
|
|
172
|
-
-?*) # Unknown
|
|
173
|
-
_dotpi_usage
|
|
174
|
-
dotpi_echo_error "Unknown audio device model: ${model}"
|
|
175
|
-
return 1
|
|
176
|
-
;;
|
|
177
|
-
|
|
178
|
-
esac
|
|
179
|
-
|
|
180
|
-
# use xargs to unquote value
|
|
181
|
-
model_project="$(dotpi_configuration_read \
|
|
182
|
-
--file "${DOTPI_ROOT}/etc/dotpi_environment_project.bash" \
|
|
183
|
-
--key dotpi_audio_device \
|
|
184
|
-
| xargs)"
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if [[ "$model_normalised" == "$(dotpi_audio_device_model_normalise "$model_project")" ]] ; then
|
|
188
|
-
# no need to update environment
|
|
189
|
-
return 0;
|
|
190
|
-
fi
|
|
191
|
-
|
|
192
|
-
dotpi_echo_warning 'Audio device model is specific to this instance'
|
|
193
|
-
|
|
194
|
-
# comment setting in project
|
|
195
|
-
dotpi_configuration_comment --file "${DOTPI_ROOT}/etc/dotpi_environment_project.bash" \
|
|
196
|
-
--key dotpi_audio_device
|
|
197
|
-
|
|
198
|
-
# escape double-quote for now, to quote when writing later
|
|
199
|
-
model_value="$(echo "$model" | dotpi_sed 's/"/\\"/g')"
|
|
200
|
-
|
|
201
|
-
# write changed setting in instance
|
|
202
|
-
# be sure to quote value
|
|
203
|
-
dotpi_configuration_write --file "${DOTPI_ROOT}/etc/dotpi_environment_instance.bash" \
|
|
204
|
-
--key dotpi_audio_device \
|
|
205
|
-
--value \""${model_value}"\"
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
_dotpi_audio_device_jackd_set_configuration() (
|
|
209
|
-
model="$1"
|
|
210
|
-
(cd "${DOTPI_ROOT}/share/jackd" && ln -s -f "dotpi_jackd_${model}.bash" 'dotpi_jackd.bash') || {
|
|
211
|
-
dotpi_echo_error "Unable to change jackd configuration to ${model}"
|
|
212
|
-
return 1
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
# we can change audio device in a temporary file-system, too
|
|
216
|
-
if dotpi_system_is_raspberry_pi ; then
|
|
217
|
-
dotpi_echo_warning "Restart jackd service"
|
|
218
|
-
service='jackd'
|
|
219
|
-
systemctl is-active "$service" > /dev/null 2>&1 \
|
|
220
|
-
&& systemctl restart "$service" || {
|
|
221
|
-
dotpi_echo_warning "systemctl unable to restart service ${service}"
|
|
222
|
-
}
|
|
223
|
-
fi
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
_dotpi_audio_device_disable_all() (
|
|
227
|
-
dotpi_echo_info "Disabling all audio devices"
|
|
228
|
-
|
|
229
|
-
_dotpi_audio_device_disable_headphones
|
|
230
|
-
_dotpi_audio_device_disable_hdmi
|
|
231
|
-
_dotpi_audio_device_disable_hifiberry
|
|
232
|
-
)
|
|
233
|
-
|
|
234
|
-
_dotpi_audio_device_select_headphones() (
|
|
235
|
-
dotpi_echo_info "Installing Headphones (default) audio device"
|
|
236
|
-
|
|
237
|
-
_dotpi_audio_device_disable_hdmi
|
|
238
|
-
_dotpi_audio_device_disable_hifiberry
|
|
239
|
-
|
|
240
|
-
# un-comment dtparam=audio as it must be set first
|
|
241
|
-
# (setting at the end the the file fails)
|
|
242
|
-
pattern="$(dotpi_configuration_get_pattern --prefix "# dtparam=audio")"
|
|
243
|
-
perl -pe "s/${pattern}/"'dtparam=audio=on/' -i "$config_file"
|
|
244
|
-
|
|
245
|
-
_dotpi_audio_device_jackd_set_configuration "headphones"
|
|
246
|
-
)
|
|
247
|
-
|
|
248
|
-
_dotpi_audio_device_select_hifiberry() (
|
|
249
|
-
dotpi_echo_info "Configuring HiFiBerry audio device '${model}'"
|
|
250
|
-
|
|
251
|
-
_dotpi_audio_device_disable_headphones
|
|
252
|
-
_dotpi_audio_device_disable_hdmi
|
|
253
|
-
_dotpi_audio_device_disable_hifiberry
|
|
254
|
-
|
|
255
|
-
mkdir -p "$(dirname -- "$config_file")"
|
|
256
|
-
cat >> "$config_file" << EOF
|
|
257
|
-
|
|
258
|
-
# dotpi: overlay for audio device '${model}'
|
|
259
|
-
dtoverlay=${dtoverlay}
|
|
260
|
-
|
|
261
|
-
EOF
|
|
262
|
-
|
|
263
|
-
_dotpi_audio_device_jackd_set_configuration "hifiberry"
|
|
264
|
-
)
|
|
265
|
-
|
|
266
|
-
_dotpi_audio_device_disable_headphones() (
|
|
267
|
-
# disable internal audio device
|
|
268
|
-
dotpi_configuration_comment --file "$config_file" --key 'dtparam=audio'
|
|
269
|
-
)
|
|
270
|
-
|
|
271
|
-
_dotpi_audio_device_disable_hdmi() (
|
|
272
|
-
# disable HDMI audio
|
|
273
|
-
|
|
274
|
-
# new systems
|
|
275
|
-
pattern="$(dotpi_configuration_get_pattern --prefix "dtoverlay=vc4-kms-v3d")"
|
|
276
|
-
perl -pe "s/${pattern}/"'${1}${2},noaudio/' -i "$config_file"
|
|
277
|
-
|
|
278
|
-
# old systems
|
|
279
|
-
pattern="$(dotpi_configuration_get_pattern --prefix "dtoverlay=vc4-fkms-v3d")"
|
|
280
|
-
perl -pe "s/${pattern}/"'${1}${2},audio=off/' -i "$config_file"
|
|
281
|
-
)
|
|
282
|
-
|
|
283
|
-
_dotpi_audio_device_disable_hifiberry() (
|
|
284
|
-
# disable hifiberry
|
|
285
|
-
pattern="$(dotpi_configuration_get_pattern --prefix "dtoverlay=hifiberry-")"
|
|
286
|
-
perl -pe "s/${pattern}/"'${1}# ${2}${3}/' -i "$config_file"
|
|
287
|
-
)
|