@dotpi/tools 2.13.0 → 2.14.0
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/dotpi_root/bin/dotpi_prepare_sd_card +3 -2
- package/dotpi_root/bin/dotpi_prepare_system +36 -12
- package/dotpi_root/dist/@dotpi/javascript/package.json +1 -2
- package/dotpi_root/dist/@dotpi/module/package.json +1 -2
- package/dotpi_root/dist/@dotpi/module-module/package.json +1 -2
- package/dotpi_root/share/dotpi_functions/dotpi_functions_audio_bluetooth.bash +22 -64
- package/dotpi_root/share/dotpi_functions/dotpi_functions_audio_device.bash +101 -125
- package/dotpi_root/share/dotpi_functions/dotpi_functions_bluetooth.bash +11 -0
- package/dotpi_root/share/dotpi_functions/dotpi_functions_user.bash +12 -0
- package/dotpi_root/share/dotpi_pipewire/dotpi_install +1 -0
- package/package.json +2 -5
- package/src/create-project.js +6 -2
- package/src/templates/dotpi_project.bash +2 -2
- package/dotpi_root/dist/@dotpi/javascript/LICENSE +0 -28
- package/dotpi_root/dist/@dotpi/module/LICENSE +0 -28
- package/dotpi_root/dist/@dotpi/module-module/LICENSE +0 -28
|
@@ -109,6 +109,9 @@ DOTPI_ROOT="${local_path}/.."
|
|
|
109
109
|
|
|
110
110
|
source "${DOTPI_ROOT}/share/dotpi_init.bash"
|
|
111
111
|
|
|
112
|
+
# not a running dotpi system
|
|
113
|
+
dotpi_filesystem_only='true'
|
|
114
|
+
|
|
112
115
|
tmp_path="${project_path}/tmp"
|
|
113
116
|
mkdir -p -- "$tmp_path"
|
|
114
117
|
|
|
@@ -502,8 +505,6 @@ if [ -f "$source_file_path" ] ; then
|
|
|
502
505
|
mkdir -p -- "$destination_path"
|
|
503
506
|
cp -- "$source_file_path" "${destination_path}/${destination_filename}"
|
|
504
507
|
fi
|
|
505
|
-
else
|
|
506
|
-
dotpi_echo_warning "firstrun.sh not found"
|
|
507
508
|
fi
|
|
508
509
|
|
|
509
510
|
# configure cmdline.txt for firstun script, if not already here
|
|
@@ -275,12 +275,6 @@ error_exit_code_audio=6
|
|
|
275
275
|
|
|
276
276
|
dotpi echo_info "Configure audio"
|
|
277
277
|
|
|
278
|
-
# set alsa default output volume and unmute
|
|
279
|
-
sudo dotpi audio_device_init || {
|
|
280
|
-
dotpi echo_warning "Error while setting default output volume and unmute for ${dotpi_audio_device} device"
|
|
281
|
-
$error_exit_code_audio
|
|
282
|
-
}
|
|
283
|
-
|
|
284
278
|
# over-ride calls to jack, to use pipewire instead
|
|
285
279
|
# copy with prefix 000- to ensure it is loaded before default aarch64-linux-gnu.conf
|
|
286
280
|
for f in /usr/share/doc/pipewire/examples/ld.so.conf.d/pipewire-jack-*.conf ; do
|
|
@@ -315,21 +309,51 @@ if [ -r "$source_path" ] ; then
|
|
|
315
309
|
fi
|
|
316
310
|
fi
|
|
317
311
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
dotpi
|
|
312
|
+
# pipewire
|
|
313
|
+
"${DOTPI_ROOT}/share/dotpi_pipewire/dotpi_install" || {
|
|
314
|
+
dotpi echo_error "error while installing dotpi_pipewire: ${?}"
|
|
321
315
|
# do not exit
|
|
322
316
|
}
|
|
323
317
|
|
|
324
|
-
"$
|
|
325
|
-
|
|
318
|
+
regular_user="$(dotpi regular_user_get_name)"
|
|
319
|
+
# Before next boot, pipewire is only available in a pi@ machine
|
|
320
|
+
sudo systemd-run --quiet --pipe --wait --collect --machine="${regular_user}@" --user -- /bin/bash -c "$(cat <<'EOF'
|
|
321
|
+
|
|
322
|
+
# wireplumber
|
|
323
|
+
systemctl --user enable --now wireplumber.service || {
|
|
324
|
+
dotpi echo_error "Error while enabling wireplumber.service now: ${?}"
|
|
325
|
+
dotpi echo_warning "wireplumber.service will be available after a reboot"
|
|
326
|
+
# do not exit
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
# wait for pipewire Master volume to be available
|
|
330
|
+
(( i_max = 60 ))
|
|
331
|
+
(( i = 0 ))
|
|
332
|
+
while ! amixer sget -- Master > /dev/null 2>&1 ; do
|
|
333
|
+
sleep 1
|
|
334
|
+
(( i++ ))
|
|
335
|
+
if (( i > i_max )) ; then
|
|
336
|
+
dotpi echo_error "Error while waiting for pipewire Master volume to be available"
|
|
337
|
+
break
|
|
338
|
+
fi
|
|
339
|
+
done
|
|
340
|
+
|
|
341
|
+
# hardware and software audio device initialisation
|
|
342
|
+
dotpi audio_device_init || {
|
|
343
|
+
dotpi echo_error "Error while initialising audio device ${dotpi_audio_device}: ${?}"
|
|
344
|
+
dotpi echo_warning "Please run 'dotpi audio_device_init' after a reboot"
|
|
345
|
+
# do not exit
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
EOF
|
|
349
|
+
)" || {
|
|
350
|
+
dotpi echo_error "Error with audio setup. Please check it after a reboot"
|
|
326
351
|
# do not exit
|
|
327
352
|
}
|
|
328
353
|
|
|
329
354
|
############## dotpi modules
|
|
330
355
|
error_exit_code_dotpi_modules=10
|
|
331
356
|
|
|
332
|
-
|
|
333
357
|
declare -A dotpi_module_uninstall_modules
|
|
334
358
|
for module in "${dotpi_module_uninstall_default[@]}" "${dotpi_module_uninstall[@]}" ; do
|
|
335
359
|
dotpi_module_uninstall_modules["$module"]=1
|
|
@@ -41,6 +41,18 @@ dotpi_audio_bluetooth_destination_connect() (
|
|
|
41
41
|
fi
|
|
42
42
|
|
|
43
43
|
if [[ "$status" == 'destination discovered' ]] ; then
|
|
44
|
+
dotpi_echo_info "Trusting destination"
|
|
45
|
+
echo "trust ${destination_mac}" >&${btctl_process[1]}
|
|
46
|
+
status='trusting'
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
if [[ "$status" == "trusting" ]] \
|
|
50
|
+
&& [[ "$output" =~ "trust succeeded" ]] ; then
|
|
51
|
+
dotpi_echo_info "Destination trusted"
|
|
52
|
+
status='destination trusted'
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
if [[ "$status" == "destination trusted" ]] ; then
|
|
44
56
|
dotpi_echo_info "Pairing destination"
|
|
45
57
|
echo "pair ${destination_mac}" >&${btctl_process[1]}
|
|
46
58
|
status='pairing'
|
|
@@ -64,28 +76,10 @@ dotpi_audio_bluetooth_destination_connect() (
|
|
|
64
76
|
if [[ "$status" == "destination paired" ]] ; then
|
|
65
77
|
dotpi_echo_info "Connecting destination"
|
|
66
78
|
echo "connect ${destination_mac}" >&${btctl_process[1]}
|
|
67
|
-
status='
|
|
68
|
-
fi
|
|
69
|
-
|
|
70
|
-
if [[ "$status" == "connecting" ]] \
|
|
71
|
-
&& [[ "$output" =~ "Connection successful" ]] ; then
|
|
72
|
-
dotpi_echo_info "Destination connected"
|
|
73
|
-
status='destination connected'
|
|
74
|
-
fi
|
|
75
|
-
|
|
76
|
-
if [[ "$status" == "destination connected" ]] ; then
|
|
77
|
-
dotpi_echo_info "Trusting destination"
|
|
78
|
-
echo "trust ${destination_mac}" >&${btctl_process[1]}
|
|
79
|
-
status='trusting'
|
|
80
|
-
fi
|
|
81
|
-
|
|
82
|
-
if [[ "$status" == "trusting" ]] \
|
|
83
|
-
&& [[ "$output" =~ "trust succeeded" ]] ; then
|
|
84
|
-
dotpi_echo_info "Destination trusted"
|
|
85
|
-
status='destination trusted'
|
|
79
|
+
status='destination paired'
|
|
86
80
|
fi
|
|
87
81
|
|
|
88
|
-
if [[ "$status" == "destination
|
|
82
|
+
if [[ "$status" == "destination paired" ]] ; then
|
|
89
83
|
dotpi_echo_info "Ending scan"
|
|
90
84
|
echo "scan off" >&${btctl_process[1]}
|
|
91
85
|
status='ending scan'
|
|
@@ -105,6 +99,8 @@ dotpi_audio_bluetooth_destination_connect() (
|
|
|
105
99
|
fi
|
|
106
100
|
|
|
107
101
|
done <&${btctl_process[0]}
|
|
102
|
+
|
|
103
|
+
dotpi_audio_bluetooth_destination_volume_init
|
|
108
104
|
)
|
|
109
105
|
|
|
110
106
|
dotpi_audio_bluetooth_destination_disconnect() (
|
|
@@ -164,8 +160,8 @@ _dotpi_audio_bluetooth_destination_start_ue() (
|
|
|
164
160
|
echo "$output" >&2
|
|
165
161
|
|
|
166
162
|
# Connected and transport volume available
|
|
167
|
-
if [[ "$output" =~ [CHG].*Transport.*/org/bluez/.*dev_"${destination_descriptor}"
|
|
168
|
-
|| [[ "$output" =~
|
|
163
|
+
if [[ "$output" =~ [CHG].*Transport.*/org/bluez/.*dev_"${destination_descriptor}" ]] \
|
|
164
|
+
|| [[ "$output" =~ [NEW].*Transport.*/org/bluez/.*dev_"${destination_descriptor}" ]] ; then
|
|
169
165
|
kill ${btctl_process_PID}
|
|
170
166
|
dotpi_echo_info "Destination started"
|
|
171
167
|
return 0
|
|
@@ -296,51 +292,13 @@ dotpi_audio_bluetooth_destination_stop() (
|
|
|
296
292
|
|
|
297
293
|
# set and save volume
|
|
298
294
|
dotpi_audio_bluetooth_destination_volume_set() (
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
destination_transport="$(bluetoothctl transport.list \
|
|
302
|
-
| perl -ne 'if(m/Transport\s+(\/*${destination_device}[^\s]+).*$/) { print "${1}\n"; }')"
|
|
303
|
-
|
|
304
|
-
if [[ -z "$destination_transport" ]] ; then
|
|
305
|
-
dotpi_echo_error "Failed to set volume: audio bluetooth device not found"
|
|
306
|
-
return 1
|
|
307
|
-
fi
|
|
308
|
-
|
|
309
|
-
bluetoothctl transport.volume "$destination_transport" "$destination_volume"
|
|
310
|
-
if (( $? != 0 )) ; then
|
|
311
|
-
dotpi_echo_error "Failed to set bluetooth destination volume"
|
|
312
|
-
return 1
|
|
313
|
-
else
|
|
314
|
-
dotpi_echo_info "Bluetooth destination volume set to ${destination_volume}"
|
|
315
|
-
fi
|
|
316
|
-
|
|
317
|
-
if [[ "$destination_volume" == "$dotpi_audio_volume" ]] ; then
|
|
318
|
-
# no change to write
|
|
319
|
-
return 0
|
|
320
|
-
fi
|
|
321
|
-
|
|
322
|
-
# comment setting in project
|
|
323
|
-
dotpi_configuration_comment --file "${DOTPI_ROOT}/etc/dotpi_environment_project.bash" \
|
|
324
|
-
--key dotpi_audio_volume
|
|
325
|
-
|
|
326
|
-
# escape double-quote for now, to quote when writing later
|
|
327
|
-
model_value="$(echo "$model" | dotpi_sed 's/"/\\"/g')"
|
|
328
|
-
|
|
329
|
-
# write changed setting in instance
|
|
330
|
-
dotpi_configuration_write --file "${DOTPI_ROOT}/etc/dotpi_environment_instance.bash" \
|
|
331
|
-
--key dotpi_audio_volume \
|
|
332
|
-
--value "$destination_volume"
|
|
333
|
-
|
|
295
|
+
# keep for compatibility
|
|
296
|
+
dotpi_audio_device_volume_set "$@"
|
|
334
297
|
)
|
|
335
298
|
|
|
336
299
|
# set volume to default
|
|
337
300
|
dotpi_audio_bluetooth_destination_volume_init() (
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
return 0
|
|
341
|
-
fi
|
|
342
|
-
|
|
343
|
-
destination_volume="$dotpi_audio_volume"
|
|
344
|
-
dotpi_audio_bluetooth_destination_volume_set "$destination_volume"
|
|
301
|
+
# keep for compatibility
|
|
302
|
+
dotpi_audio_device_volume_init
|
|
345
303
|
)
|
|
346
304
|
|
|
@@ -34,6 +34,7 @@ dotpi_audio_device_supported=(
|
|
|
34
34
|
'raspberry pi digiamp+'
|
|
35
35
|
'raspiaudio mic+ v1'
|
|
36
36
|
'raspiaudio mic+ v2'
|
|
37
|
+
'raspiaudio mic+ v3'
|
|
37
38
|
'raspiaudio ultra'
|
|
38
39
|
'ue boom 2'
|
|
39
40
|
'ue boom 3'
|
|
@@ -271,10 +272,17 @@ dotpi_audio_device_select() (
|
|
|
271
272
|
_dotpi_audio_device_select_raspiaudio
|
|
272
273
|
;;
|
|
273
274
|
|
|
275
|
+
'raspiaudio mic+ v3')
|
|
276
|
+
# driver in kernel
|
|
277
|
+
dtoverlay=''
|
|
278
|
+
_dotpi_audio_device_select_raspiaudio
|
|
279
|
+
;;
|
|
280
|
+
|
|
281
|
+
|
|
274
282
|
# Raspiaudio ULTRA (WM8960 codec, driver in kernel)
|
|
275
283
|
# Cf. https://forum.raspiaudio.com/t/ultra-installation-guide/21
|
|
276
284
|
'raspiaudio ultra')
|
|
277
|
-
dtoverlay=wm8960-soundcard
|
|
285
|
+
dtoverlay='wm8960-soundcard'
|
|
278
286
|
_dotpi_audio_device_select_raspiaudio
|
|
279
287
|
;;
|
|
280
288
|
|
|
@@ -307,11 +315,10 @@ dotpi_audio_device_select() (
|
|
|
307
315
|
return 0;
|
|
308
316
|
fi
|
|
309
317
|
|
|
310
|
-
dotpi_echo_warning 'Audio device model is specific to this instance'
|
|
311
318
|
|
|
312
319
|
# comment setting in project
|
|
313
320
|
dotpi_configuration_comment --file "${DOTPI_ROOT}/etc/dotpi_environment_project.bash" \
|
|
314
|
-
|
|
321
|
+
--key dotpi_audio_device
|
|
315
322
|
|
|
316
323
|
# escape double-quote for now, to quote when writing later
|
|
317
324
|
model_value="$(echo "$model" | dotpi_sed 's/"/\\"/g')"
|
|
@@ -319,46 +326,32 @@ dotpi_audio_device_select() (
|
|
|
319
326
|
# write changed setting in instance
|
|
320
327
|
# be sure to quote value
|
|
321
328
|
dotpi_configuration_write --file "${DOTPI_ROOT}/etc/dotpi_environment_instance.bash" \
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
)
|
|
325
|
-
|
|
326
|
-
_dotpi_audio_device_disable_all() (
|
|
327
|
-
exception_family="$1"
|
|
328
|
-
|
|
329
|
-
if [[ "$exception_family" = "" ]] ; then
|
|
330
|
-
dotpi_echo_info "Disabling all audio devices"
|
|
331
|
-
else
|
|
332
|
-
dotpi_echo_info "Disabling all audio devices except ${exception_family}"
|
|
333
|
-
fi
|
|
329
|
+
--key dotpi_audio_device \
|
|
330
|
+
--value \""${model_value}"\"
|
|
334
331
|
|
|
335
|
-
|
|
336
|
-
_dotpi_audio_device_disable_headphones
|
|
337
|
-
fi
|
|
338
|
-
|
|
339
|
-
if [[ ! "$exception_family" = "hdmi" ]] ; then
|
|
340
|
-
_dotpi_audio_device_disable_hdmi
|
|
341
|
-
fi
|
|
332
|
+
source "${DOTPI_ROOT}/etc/dotpi_environment_instance.bash"
|
|
342
333
|
|
|
343
|
-
|
|
344
|
-
|
|
334
|
+
# test for a running dotpi system
|
|
335
|
+
if [[ -z "$dotpi_filesystem_only" ]] ; then
|
|
336
|
+
dotpi_echo_warning "To finalise the audio device selection, please reboot and run 'sudo dotpi audio_device_init'"
|
|
345
337
|
fi
|
|
338
|
+
)
|
|
346
339
|
|
|
347
|
-
|
|
348
|
-
_dotpi_audio_device_disable_hifiberry
|
|
349
|
-
fi
|
|
340
|
+
_dotpi_audio_device_disable_all() (
|
|
350
341
|
|
|
351
|
-
|
|
352
|
-
_dotpi_audio_device_disable_raspiaudio
|
|
353
|
-
fi
|
|
342
|
+
dotpi_echo_info "Disabling all audio devices"
|
|
354
343
|
|
|
344
|
+
_dotpi_audio_device_disable_headphones
|
|
345
|
+
_dotpi_audio_device_disable_hdmi
|
|
346
|
+
_dotpi_audio_device_disable_raspberry_pi
|
|
347
|
+
_dotpi_audio_device_disable_hifiberry
|
|
348
|
+
_dotpi_audio_device_disable_raspiaudio
|
|
355
349
|
)
|
|
356
350
|
|
|
357
351
|
_dotpi_audio_device_select_headphones() (
|
|
352
|
+
_dotpi_audio_device_disable_all
|
|
358
353
|
dotpi_echo_info "Installing Headphones (default) audio device"
|
|
359
354
|
|
|
360
|
-
_dotpi_audio_device_disable_all headphones
|
|
361
|
-
|
|
362
355
|
# un-comment dtparam=audio as it must be set first
|
|
363
356
|
# (setting at the end the the file fails)
|
|
364
357
|
pattern="$(dotpi_configuration_get_pattern --prefix "# dtparam=audio")"
|
|
@@ -366,17 +359,14 @@ _dotpi_audio_device_select_headphones() (
|
|
|
366
359
|
)
|
|
367
360
|
|
|
368
361
|
_dotpi_audio_device_select_bluetooth() (
|
|
369
|
-
_dotpi_audio_device_disable_all
|
|
370
|
-
|
|
371
|
-
rfkill unblock all
|
|
372
|
-
sudo bluetoothctl power on
|
|
362
|
+
_dotpi_audio_device_disable_all
|
|
363
|
+
dotpi_echo_info "Enabling Bluetooth"
|
|
373
364
|
)
|
|
374
365
|
|
|
375
366
|
_dotpi_audio_device_select_raspberry_pi() (
|
|
367
|
+
_dotpi_audio_device_disable_all
|
|
376
368
|
dotpi_echo_info "Configuring Raspberry Pi audio device '${model}'"
|
|
377
369
|
|
|
378
|
-
_dotpi_audio_device_disable_all raspberry_pi
|
|
379
|
-
|
|
380
370
|
mkdir -p "$(dirname -- "$config_file")"
|
|
381
371
|
cat >> "$config_file" << EOF
|
|
382
372
|
|
|
@@ -388,10 +378,9 @@ EOF
|
|
|
388
378
|
|
|
389
379
|
|
|
390
380
|
_dotpi_audio_device_select_hifiberry() (
|
|
381
|
+
_dotpi_audio_device_disable_all
|
|
391
382
|
dotpi_echo_info "Configuring HiFiBerry audio device '${model}'"
|
|
392
383
|
|
|
393
|
-
_dotpi_audio_device_disable_all hifiberry
|
|
394
|
-
|
|
395
384
|
mkdir -p "$(dirname -- "$config_file")"
|
|
396
385
|
cat >> "$config_file" << EOF
|
|
397
386
|
|
|
@@ -402,9 +391,12 @@ EOF
|
|
|
402
391
|
)
|
|
403
392
|
|
|
404
393
|
_dotpi_audio_device_select_raspiaudio() (
|
|
394
|
+
_dotpi_audio_device_disable_all
|
|
405
395
|
dotpi_echo_info "Configuring Raspiaudio device '${model}'"
|
|
406
396
|
|
|
407
|
-
|
|
397
|
+
if [[ "$dtoverlay" == "" ]] ; then
|
|
398
|
+
return 0
|
|
399
|
+
fi
|
|
408
400
|
|
|
409
401
|
mkdir -p "$(dirname -- "$config_file")"
|
|
410
402
|
cat >> "$config_file" << EOF
|
|
@@ -461,8 +453,7 @@ _dotpi_audio_device_disable_raspiaudio() (
|
|
|
461
453
|
)
|
|
462
454
|
|
|
463
455
|
_dotpi_audio_device_volume_set_alsa() (
|
|
464
|
-
amixer -- sset "$control" "$volume"
|
|
465
|
-
alsactl store
|
|
456
|
+
amixer -D sysdefault -- sset "$control" "$volume"
|
|
466
457
|
|
|
467
458
|
if [[ "$volume" == "$dotpi_audio_volume" ]] ; then
|
|
468
459
|
# no change to write
|
|
@@ -478,8 +469,8 @@ _dotpi_audio_device_volume_set_alsa() (
|
|
|
478
469
|
|
|
479
470
|
# write changed setting in instance
|
|
480
471
|
dotpi_configuration_write --file "${DOTPI_ROOT}/etc/dotpi_environment_instance.bash" \
|
|
481
|
-
|
|
482
|
-
|
|
472
|
+
--key dotpi_audio_volume \
|
|
473
|
+
--value "$volume"
|
|
483
474
|
)
|
|
484
475
|
|
|
485
476
|
dotpi_audio_device_init() (
|
|
@@ -500,14 +491,16 @@ dotpi_audio_device_init() (
|
|
|
500
491
|
|
|
501
492
|
# clone once to be able to init offline
|
|
502
493
|
if ! [[ -d "${usr_directory}" ]] ; then
|
|
503
|
-
mkdir -p "${usr_directory}"
|
|
504
|
-
git clone "https://github.com/${usr_repository}.git" "${usr_directory}" || {
|
|
494
|
+
sudo mkdir -p "${usr_directory}"
|
|
495
|
+
sudo git clone "https://github.com/${usr_repository}.git" "${usr_directory}" || {
|
|
505
496
|
dotpi_echo_error "Unable to clone repository ${usr_repository}"
|
|
506
497
|
return 1
|
|
507
498
|
}
|
|
508
499
|
fi
|
|
509
500
|
|
|
510
|
-
alsactl restore
|
|
501
|
+
alsactl restore \
|
|
502
|
+
--file "${usr_directory}/Codec_Zero_StereoMIC_record_and_HP_playback.state" \
|
|
503
|
+
hw:0
|
|
511
504
|
;;
|
|
512
505
|
|
|
513
506
|
'raspiaudio ultra')
|
|
@@ -517,27 +510,26 @@ dotpi_audio_device_init() (
|
|
|
517
510
|
|
|
518
511
|
# clone once to be able to init offline
|
|
519
512
|
if ! [[ -d "${usr_directory}" ]] ; then
|
|
520
|
-
mkdir -p "${usr_directory}"
|
|
521
|
-
git clone "https://github.com/${usr_repository}.git" "${usr_directory}" || {
|
|
513
|
+
sudo mkdir -p "${usr_directory}"
|
|
514
|
+
sudo git clone "https://github.com/${usr_repository}.git" "${usr_directory}" || {
|
|
522
515
|
dotpi_echo_error "Unable to clone repository ${usr_repository}"
|
|
523
516
|
return 1
|
|
524
517
|
}
|
|
525
518
|
fi
|
|
526
519
|
|
|
527
520
|
# routes DAC to headphones and speakers, onboard mics to ADC
|
|
528
|
-
alsactl restore
|
|
521
|
+
alsactl restore \
|
|
522
|
+
--file "${usr_directory}/headphones.alsa" \
|
|
523
|
+
hw:0
|
|
529
524
|
;;
|
|
530
|
-
|
|
531
|
-
esac
|
|
525
|
+
esac
|
|
532
526
|
|
|
533
527
|
# alsa
|
|
534
528
|
case "$model_normalised" in
|
|
535
529
|
|
|
536
530
|
'headphones')
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
amixer -D sysdefault sset -- 'PCM' '0dB'
|
|
540
|
-
alsactl store
|
|
531
|
+
# 'PCM' control is aliased to default master
|
|
532
|
+
# no need for concurrent control
|
|
541
533
|
;;
|
|
542
534
|
|
|
543
535
|
'raspberry pi dac pro'|'iqaudio dac pro' \
|
|
@@ -550,104 +542,88 @@ dotpi_audio_device_init() (
|
|
|
550
542
|
|
|
551
543
|
amixer -D sysdefault sset -- 'Lineout' 'on'
|
|
552
544
|
amixer -D sysdefault sset -- 'Lineout' '0dB'
|
|
553
|
-
|
|
554
|
-
alsactl store
|
|
555
545
|
;;
|
|
556
546
|
|
|
557
|
-
'raspiaudio mic+ v1' | 'raspiaudio mic+ v2')
|
|
558
|
-
|
|
559
|
-
# no controller for device, use default 'Master' control
|
|
560
|
-
amixer sset -- 'Master' 'on'
|
|
561
|
-
amixer sset -- 'Master' '80%'
|
|
562
|
-
|
|
563
|
-
alsactl store
|
|
564
|
-
;;
|
|
565
|
-
|
|
566
|
-
esac
|
|
567
|
-
|
|
568
|
-
)
|
|
569
|
-
|
|
570
|
-
# set and store volume for the current audio device
|
|
571
|
-
dotpi_audio_device_volume_set() (
|
|
572
|
-
volume="$1"
|
|
573
|
-
|
|
574
|
-
model="$dotpi_audio_device"
|
|
575
|
-
# lowercase everything
|
|
576
|
-
model_normalised="$(dotpi_audio_device_model_normalise "$model")"
|
|
577
|
-
|
|
578
|
-
case "$model_normalised" in
|
|
579
|
-
|
|
580
|
-
####### Generic devices
|
|
581
|
-
|
|
582
|
-
'headphones')
|
|
583
|
-
control='PCM'
|
|
584
|
-
_dotpi_audio_device_volume_set_alsa
|
|
585
|
-
;;
|
|
586
|
-
|
|
587
|
-
'bluetooth')
|
|
588
|
-
dotpi_audio_bluetooth_destination_volume_set "$volume"
|
|
589
|
-
;;
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
####### Specific devices
|
|
593
|
-
|
|
594
|
-
# HiFiBerry
|
|
595
|
-
# Cf. https://www.hifiberry.com/docs/archive/mixer-controls-on-the-hifiberry-boards/
|
|
596
|
-
|
|
597
|
-
|
|
598
547
|
'hifiberry dac+ dsp'|'hifiberry dac+ rtc'|'hifiberry dac+ standard'|'hifiberry amp2'|'hifiberry dac+ adc'|'hifiberry dac+ adc pro'|'hifiberry amp3')
|
|
599
548
|
control='Digital'
|
|
600
|
-
|
|
549
|
+
amixer -D sysdefault sset -- "$control" 'on'
|
|
550
|
+
amixer -D sysdefault sset -- "$control" '0dB'
|
|
601
551
|
;;
|
|
602
552
|
|
|
603
553
|
'hifiberry dac2 hd')
|
|
604
554
|
control='DAC'
|
|
605
|
-
|
|
555
|
+
amixer -D sysdefault sset -- "$control" 'on'
|
|
556
|
+
amixer -D sysdefault sset -- "$control" '0dB'
|
|
606
557
|
;;
|
|
607
558
|
|
|
608
559
|
'hifiberry amp+'|'hifiberry amp4'|'hifiberry amp4 pro')
|
|
609
560
|
control='Master'
|
|
610
|
-
|
|
561
|
+
amixer -D sysdefault sset -- "$control" 'on'
|
|
562
|
+
amixer -D sysdefault sset -- "$control" '0dB'
|
|
611
563
|
;;
|
|
612
564
|
|
|
613
|
-
|
|
614
|
-
control='Master'
|
|
615
|
-
_dotpi_audio_device_volume_set_alsa
|
|
616
|
-
;;
|
|
565
|
+
esac
|
|
617
566
|
|
|
618
|
-
'raspiaudio ultra')
|
|
619
|
-
# WM8960 DAC digital volume, acts on both headphones and speakers
|
|
620
|
-
control='Playback'
|
|
621
|
-
_dotpi_audio_device_volume_set_alsa
|
|
622
|
-
;;
|
|
623
567
|
|
|
568
|
+
dotpi_audio_device_volume_init
|
|
569
|
+
)
|
|
624
570
|
|
|
625
|
-
|
|
571
|
+
# set and store volume for the current audio device
|
|
572
|
+
dotpi_audio_device_volume_set() (
|
|
626
573
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
574
|
+
# Master volume is handled by pipewire, and pipewire requires a regular user session.
|
|
575
|
+
if [[ "$USER" == "root" ]]; then
|
|
576
|
+
# drop sudo privileges
|
|
577
|
+
dotpi_regular_user_run dotpi audio_device_volume_set "$@"
|
|
578
|
+
return $?
|
|
579
|
+
fi
|
|
630
580
|
|
|
631
|
-
|
|
581
|
+
volume="$1"
|
|
632
582
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
583
|
+
if [[ -z "$volume" ]] ; then
|
|
584
|
+
dotpi_echo_error "Missing volume argument"
|
|
585
|
+
return 1
|
|
586
|
+
fi
|
|
587
|
+
|
|
588
|
+
if [[ ! "$volume" =~ %$ ]] ; then
|
|
589
|
+
dotpi_echo_error "Volume argument must be a percentage (e.g. '40%')"
|
|
590
|
+
return 1
|
|
591
|
+
fi
|
|
637
592
|
|
|
593
|
+
amixer -D default sset -- Master "$volume" || {
|
|
594
|
+
error_code=$?
|
|
595
|
+
dotpi_echo_error "Unable to set volume to ${volume}"
|
|
596
|
+
return "$error_code"
|
|
597
|
+
}
|
|
638
598
|
|
|
639
|
-
|
|
599
|
+
if [[ "$volume" == "$dotpi_audio_volume" ]] ; then
|
|
600
|
+
# no change to write
|
|
601
|
+
return 0
|
|
602
|
+
fi
|
|
603
|
+
|
|
604
|
+
# comment setting in project
|
|
605
|
+
sudo dotpi configuration_comment --file "${DOTPI_ROOT}/etc/dotpi_environment_project.bash" \
|
|
606
|
+
--key dotpi_audio_volume
|
|
607
|
+
|
|
608
|
+
# escape double-quote for now, to quote when writing later
|
|
609
|
+
model_value="$(echo "$model" | dotpi_sed 's/"/\\"/g')"
|
|
610
|
+
|
|
611
|
+
# write changed setting in instance
|
|
612
|
+
sudo dotpi configuration_write --file "${DOTPI_ROOT}/etc/dotpi_environment_instance.bash" \
|
|
613
|
+
--key dotpi_audio_volume \
|
|
614
|
+
--value "$volume"
|
|
640
615
|
)
|
|
641
616
|
|
|
642
617
|
# restore volume for the current audio device
|
|
643
618
|
dotpi_audio_device_volume_init() (
|
|
644
|
-
|
|
619
|
+
volume="$dotpi_audio_volume"
|
|
620
|
+
|
|
621
|
+
if [[ -z "$volume" ]] ; then
|
|
645
622
|
dotpi_echo_warning "dotpi_audio_volume not set, keeping default volume"
|
|
646
623
|
return 0
|
|
647
624
|
fi
|
|
648
625
|
|
|
649
|
-
|
|
650
|
-
dotpi_audio_device_volume_set "$destination_volume"
|
|
626
|
+
dotpi_audio_device_volume_set "$volume"
|
|
651
627
|
)
|
|
652
628
|
|
|
653
629
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
3
|
dotpi_regular_user_get_id() (
|
|
4
|
+
# 1000 is the default user id for the first user on a Raspberry Pi OS system
|
|
4
5
|
regular_user_id="${SUDO_UID:-1000}"
|
|
5
6
|
if (( regular_user_id == 0 )) ; then
|
|
6
7
|
regular_user_id=1000
|
|
@@ -26,3 +27,14 @@ dotpi_regular_user_get_home() (
|
|
|
26
27
|
regular_user_home="$(getent passwd "$regular_user_id" | cut -d: -f6)"
|
|
27
28
|
echo "$regular_user_home"
|
|
28
29
|
)
|
|
30
|
+
|
|
31
|
+
dotpi_regular_user_run() (
|
|
32
|
+
if [[ "$USER" == "root" ]]; then
|
|
33
|
+
regular_user="$(dotpi_regular_user_get_name)"
|
|
34
|
+
# no sudo as user is root
|
|
35
|
+
# prefer systemd-run as it returns the exit code (unlike machinectl shell)
|
|
36
|
+
systemd-run --quiet --pipe --wait --collect --machine="${regular_user}@" --user -- /bin/bash -c '"$@"' - "$@"
|
|
37
|
+
else
|
|
38
|
+
"$@"
|
|
39
|
+
fi
|
|
40
|
+
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotpi/tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"description": "Set of scripts for managing dotpi fleets of Raspberry Pi",
|
|
5
5
|
"author": "Jean-Philippe Lambert",
|
|
6
6
|
"contributors": [
|
|
@@ -46,8 +46,5 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"lerna": "^10.1.1"
|
|
48
48
|
},
|
|
49
|
-
"
|
|
50
|
-
"nx": true
|
|
51
|
-
},
|
|
52
|
-
"gitHead": "a2a5dfe6969c72dbf0e79466b969e0cfa9cb453f"
|
|
49
|
+
"gitHead": "f67c59b77ca5361bd56c6f3a1b6275d7836638c2"
|
|
53
50
|
}
|
package/src/create-project.js
CHANGED
|
@@ -98,8 +98,12 @@ export async function configureProject(data, mocks = null) {
|
|
|
98
98
|
const answers = await prompts([
|
|
99
99
|
{
|
|
100
100
|
type: 'select',
|
|
101
|
-
name: '
|
|
102
|
-
message:
|
|
101
|
+
name: 'audioDevice',
|
|
102
|
+
message: `Choose your audio device.
|
|
103
|
+
> Select 'default' to keep all the default devices (eg. headphones, HDMI).
|
|
104
|
+
> Select 'none' to keep only automatically configured devices (e.g. USB, raspiaudio mic+ v3).
|
|
105
|
+
> Select a specific device to keep only this one, and to configure it.
|
|
106
|
+
`,
|
|
103
107
|
choices: readBashArray('dotpi_audio_device_supported').map(s => ({ title: s, value: s })),
|
|
104
108
|
},
|
|
105
109
|
{
|
|
@@ -6,8 +6,8 @@ dotpi_tools_version='${d.version}'
|
|
|
6
6
|
# Project name
|
|
7
7
|
dotpi_project_name='${d.projectName}'
|
|
8
8
|
|
|
9
|
-
# Define
|
|
10
|
-
dotpi_audio_device='${d.
|
|
9
|
+
# Define audio device
|
|
10
|
+
dotpi_audio_device='${d.audioDevice}'
|
|
11
11
|
|
|
12
12
|
# Node.js version
|
|
13
13
|
dotpi_node_version='${d.nodeVersion}'
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2023-present IRCAM – Centre Pompidou (France, Paris)
|
|
2
|
-
|
|
3
|
-
All rights reserved.
|
|
4
|
-
|
|
5
|
-
Redistribution and use in source and binary forms, with or without modification,
|
|
6
|
-
are permitted provided that the following conditions are met:
|
|
7
|
-
|
|
8
|
-
* Redistributions of source code must retain the above copyright notice, this
|
|
9
|
-
list of conditions and the following disclaimer.
|
|
10
|
-
|
|
11
|
-
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
12
|
-
list of conditions and the following disclaimer in the documentation and/or
|
|
13
|
-
other materials provided with the distribution.
|
|
14
|
-
|
|
15
|
-
* Neither the name of the IRCAM nor the names of its
|
|
16
|
-
contributors may be used to endorse or promote products derived from
|
|
17
|
-
this software without specific prior written permission.
|
|
18
|
-
|
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
20
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
21
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
23
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
24
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
25
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
26
|
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
27
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
28
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2023-present IRCAM – Centre Pompidou (France, Paris)
|
|
2
|
-
|
|
3
|
-
All rights reserved.
|
|
4
|
-
|
|
5
|
-
Redistribution and use in source and binary forms, with or without modification,
|
|
6
|
-
are permitted provided that the following conditions are met:
|
|
7
|
-
|
|
8
|
-
* Redistributions of source code must retain the above copyright notice, this
|
|
9
|
-
list of conditions and the following disclaimer.
|
|
10
|
-
|
|
11
|
-
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
12
|
-
list of conditions and the following disclaimer in the documentation and/or
|
|
13
|
-
other materials provided with the distribution.
|
|
14
|
-
|
|
15
|
-
* Neither the name of the IRCAM nor the names of its
|
|
16
|
-
contributors may be used to endorse or promote products derived from
|
|
17
|
-
this software without specific prior written permission.
|
|
18
|
-
|
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
20
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
21
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
23
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
24
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
25
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
26
|
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
27
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
28
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2023-present IRCAM – Centre Pompidou (France, Paris)
|
|
2
|
-
|
|
3
|
-
All rights reserved.
|
|
4
|
-
|
|
5
|
-
Redistribution and use in source and binary forms, with or without modification,
|
|
6
|
-
are permitted provided that the following conditions are met:
|
|
7
|
-
|
|
8
|
-
* Redistributions of source code must retain the above copyright notice, this
|
|
9
|
-
list of conditions and the following disclaimer.
|
|
10
|
-
|
|
11
|
-
* Redistributions in binary form must reproduce the above copyright notice, this
|
|
12
|
-
list of conditions and the following disclaimer in the documentation and/or
|
|
13
|
-
other materials provided with the distribution.
|
|
14
|
-
|
|
15
|
-
* Neither the name of the IRCAM nor the names of its
|
|
16
|
-
contributors may be used to endorse or promote products derived from
|
|
17
|
-
this software without specific prior written permission.
|
|
18
|
-
|
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
20
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
21
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
23
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
24
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
25
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
26
|
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
27
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
28
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|