@dotpi/tools 1.0.0 → 1.3.3

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.
@@ -156,7 +156,13 @@ sudo dotpi service_install "${DOTPI_ROOT}/share/dotpi_avahi_monitor/dotpi_avahi_
156
156
  }
157
157
 
158
158
  ############## pipewire (and jackd compatibility)
159
- error_exit_code_pipewire=6
159
+ error_exit_code_audio=6
160
+
161
+ # set alsa default output volume and unmute
162
+ sudo dotpi audio_device_init || {
163
+ dotpi echo_warning "Error while setting default output volume and unmute for ${dotpi_audio_device} device" \
164
+ $error_exit_code_audio
165
+ }
160
166
 
161
167
  # over-ride calls to jackd
162
168
  # copy with prefix 0- to ensure it is loaded before default aarch64-linux-gnu.conf
@@ -164,11 +170,11 @@ for f in /usr/share/doc/pipewire/examples/ld.so.conf.d/pipewire-jack-*.conf ; do
164
170
  source_basename="$(basename "$f")"
165
171
  destination_basename="0-${source_basename}"
166
172
  sudo cp "$f" "/etc/ld.so.conf.d/${destination_basename}" || {
167
- error_exit $? "install ${f}" $error_exit_code_pipewire
173
+ error_exit $? "install ${f}" $error_exit_code_audio
168
174
  }
169
175
  done
170
176
  sudo ldconfig || {
171
- error_exit $? "ldconfig" $error_exit_code_pipewire
177
+ error_exit $? "ldconfig" $error_exit_code_audio
172
178
  }
173
179
 
174
180
  systemctl --user enable --now wireplumber.service || {
@@ -20,12 +20,20 @@ dotpi_audio_device_supported=(
20
20
  'hifiberry digi+ pro'
21
21
  'hifiberry amp+'
22
22
  'hifiberry amp3'
23
+ 'hifiberry dac for raspberry pi 1'
24
+ 'raspberry pi dac pro'
25
+ 'raspberry pi dac+'
26
+ 'raspberry pi digiamp+'
27
+ 'raspberry pi codec zero'
28
+ 'iqaudio dac pro'
29
+ 'iqaudio dac+'
30
+ 'iqaudio digiamp+'
31
+ 'iqaudio codec zero'
23
32
  'bluetooth'
24
33
  'ue boom 2'
25
34
  'ue boom 3'
26
35
  'ue megaboom 2'
27
36
  'ue megaboom 3'
28
- 'hifiberry dac for raspberry pi 1'
29
37
  )
30
38
 
31
39
  _dotpi_audio_device_get_options() {
@@ -163,22 +171,22 @@ dotpi_audio_device_select() (
163
171
  # Raspberry
164
172
  # Cf. https://www.raspberrypi.com/documentation/accessories/audio.html#configuration
165
173
 
166
- 'raspberry pi dac pro')
174
+ 'raspberry pi dac pro'|'iqaudio dac pro')
167
175
  dtoverlay=rpi-dacpro
168
176
  _dotpi_audio_device_select_raspberry_pi
169
177
  ;;
170
178
 
171
- 'raspberry pi dac+')
172
- dtoverlay=rpi-dacplus
179
+ 'raspberry pi dac+'|'iqaudio dac+')
180
+ dtoverlay='rpi-dacplus,auto_mute_amp'
173
181
  _dotpi_audio_device_select_raspberry_pi
174
182
  ;;
175
183
 
176
- 'raspberry pi digiamp+')
177
- dtoverlay=rpi-digiampplus
184
+ 'raspberry pi digiamp+'|'iqaudio digiamp+')
185
+ dtoverlay='rpi-digiampplus,auto_mute_amp'
178
186
  _dotpi_audio_device_select_raspberry_pi
179
187
  ;;
180
188
 
181
- 'raspberry pi codec zero')
189
+ 'raspberry pi codec zero'|'iqaudio codec zero')
182
190
  dtoverlay=rpi-codeczero
183
191
  _dotpi_audio_device_select_raspberry_pi
184
192
  ;;
@@ -430,6 +438,64 @@ _dotpi_audio_device_volume_set_alsa() (
430
438
  --value "$volume"
431
439
  )
432
440
 
441
+ dotpi_audio_device_init() (
442
+
443
+ if [[ -z "$dotpi_audio_device" ]] ; then
444
+ dotpi_echo_warning "dotpi_audio_device not set, keeping default audio device"
445
+ return 0
446
+ fi
447
+
448
+ model_normalised="$(dotpi_audio_device_model_normalise "$dotpi_audio_device")"
449
+
450
+ # hardware
451
+ case "$model_normalised" in
452
+ 'raspberry pi codec zero'|'iqaudio codec zero')
453
+
454
+ usr_repository="raspberrypi/Pi-Codec"
455
+ usr_directory="${DOTPI_ROOT}/usr/${usr_repository}"
456
+
457
+ # clone once to be able to init offline
458
+ if ! [[ -d "${usr_directory}" ]] ; then
459
+ mkdir -p "${usr_directory}"
460
+ git clone "https://github.com/${usr_repository}.git" "${usr_directory}" || {
461
+ dotpi_echo_error "Unable to clone repository ${usr_repository}"
462
+ return 1
463
+ }
464
+ fi
465
+
466
+ alsactl restore -f "${usr_directory}/Codec_Zero_StereoMIC_record_and_HP_playback.state"
467
+ ;;
468
+
469
+ esac
470
+
471
+ # alsa
472
+ case "$model_normalised" in
473
+
474
+ 'headphones')
475
+
476
+ amixer -D sysdefault sset -- 'PCM' 'on'
477
+ amixer -D sysdefault sset -- 'PCM' '0dB'
478
+ alsactl store
479
+ ;;
480
+
481
+ 'raspberry pi dac pro'|'iqaudio dac pro' \
482
+ | 'raspberry pi dac+'|'iqaudio dac+' \
483
+ | 'raspberry pi digiamp+'|'iqaudio digiamp+' \
484
+ | 'raspberry pi codec zero'|'iqaudio codec zero')
485
+
486
+ amixer -D sysdefault sset -- 'Headphone' 'on'
487
+ amixer -D sysdefault sset -- 'Headphone' '0dB'
488
+
489
+ amixer -D sysdefault sset -- 'Lineout' 'on'
490
+ amixer -D sysdefault sset -- 'Lineout' '0dB'
491
+
492
+ alsactl store
493
+ ;;
494
+
495
+ esac
496
+
497
+ )
498
+
433
499
  # set and store volume for the current audio device
434
500
  dotpi_audio_device_volume_set() (
435
501
  volume="$1"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotpi/tools",
3
- "version": "1.0.0",
3
+ "version": "1.3.3",
4
4
  "description": "Set of scripts for managing dotpi fleets of Raspberry Pi",
5
5
  "author": "Jean-Philippe Lambert",
6
6
  "contributors": [
@@ -262,7 +262,7 @@ export async function configureWiFi(data, mocks = null) {
262
262
  const configPath = path.join(PATH_NETWORK_DIRECTORY, value);
263
263
 
264
264
  if (!WIFI_ID_REGEXP.test(value)) {
265
- return 'Please provide a valid WiFi configuration id. A valid configuration id must contain only lower case letters, digits, - and _';
265
+ return 'Invalid WiFi configuration id: use only lower case letters, digits, - and _';
266
266
  } else if (fs.existsSync(configPath)) {
267
267
  return `A WiFi configuration named "${value}" already exists`;
268
268
  }
@@ -350,7 +350,7 @@ export async function injectUtilityFiles(data) {
350
350
 
351
351
  data.files[PATH_DOTPI_FILE] = JSON.stringify({ dotpiToolsVersion: packageVersion() }, null, 2);
352
352
 
353
- data.files[PATH_GITIGNORE] = renderTemplate('.gitignore', {
353
+ data.files[PATH_GITIGNORE] = renderTemplate('gitignore', {
354
354
  PATH_DOTPI_SECRETS_BASH,
355
355
  PATH_SSH_DIRECTORY,
356
356
  PATH_NETWORK_DIRECTORY,
@@ -435,4 +435,4 @@ export default async function createProject() {
435
435
  > Next Step: plug-in a SD Card with a Raspberry Pi OS (Lite) installed and run:
436
436
  > ${chalk.yellow('dotpi-tools --install-rpi')}
437
437
  `);
438
- }
438
+ }
@@ -26,6 +26,6 @@ dotpi_wifi_country_code='${d.wifiCountryCode}'
26
26
  dotpi_keymap='${d.keyMap}'
27
27
 
28
28
  # If you want to have some packages to be automatically installed
29
- # or removed by default, you can list them in the arrays above
29
+ # or removed by default, you can list them in the arrays below
30
30
  dotpi_apt_install+=()
31
31
  dotpi_apt_uninstall+=()
@@ -0,0 +1,4 @@
1
+ ${d.PATH_DOTPI_SECRETS_BASH}
2
+ ${d.PATH_SSH_DIRECTORY}
3
+ ${d.PATH_NETWORK_DIRECTORY}
4
+ ${d.PATH_DOTPI_TMP_DIRECTORY}