@@ -284,10 +284,13 @@ pre_flight_checks() {
284284
285285# --- Detect and Select USB DAC ---
286286select_audio_device () {
287+ echo
287288 cecho " yellow" " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
288289 cecho " yellow" " Step 1: Audio Device Selection"
289290 cecho " yellow" " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
290291 echo
292+ cecho " cyan" " ⏸ PLEASE RESPOND TO THIS PROMPT ⏸"
293+ echo
291294
292295 # Get list of all audio cards
293296 cecho " blue" " Scanning for audio devices..."
@@ -413,16 +416,20 @@ select_audio_device() {
413416
414417# --- Get AirPlay Name ---
415418get_airplay_name () {
419+ echo
416420 cecho " yellow" " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
417421 cecho " yellow" " Step 2: Name Your AirPlay Device"
418422 cecho " yellow" " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
419423 echo
424+ cecho " cyan" " ⏸ PLEASE RESPOND TO THIS PROMPT ⏸"
425+ echo
420426
421427 local hostname
422428 hostname=$( hostname)
423429 cecho " blue" " This is the name that will appear on your iPhone/iPad."
424430 cecho " blue" " Examples: Living Room, Bedroom Speaker, Kitchen Audio"
425431 echo
432+ cecho " green" " >>> "
426433 read -p " Enter a name (or press Enter for '$hostname AirPlay'): " airplay_name || true
427434
428435 if [ -z " $airplay_name " ]; then
@@ -438,10 +445,13 @@ get_airplay_name() {
438445
439446# --- Wi-Fi Power Management ---
440447configure_wifi () {
448+ echo
441449 cecho " yellow" " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
442450 cecho " yellow" " Step 3: Wi-Fi Optimization"
443451 cecho " yellow" " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
444452 echo
453+ cecho " cyan" " ⏸ PLEASE RESPOND TO THIS PROMPT ⏸"
454+ echo
445455
446456 # Check if Wi-Fi is actually being used
447457 if ! ip link show wlan0 & > /dev/null; then
@@ -455,6 +465,7 @@ configure_wifi() {
455465 cecho " blue" " Wi-Fi power saving can cause audio stuttering and dropouts."
456466 cecho " blue" " Disabling it ensures smooth, uninterrupted playback."
457467 echo
468+ cecho " green" " >>> "
458469 read -p " Disable Wi-Fi power saving? (Y/n): " wifi_choice || true
459470
460471 if [[ -z " $wifi_choice " || " $wifi_choice " =~ ^[Yy]$ ]]; then
@@ -493,7 +504,13 @@ main() {
493504 log " System: $( uname -a) "
494505 echo
495506
496- read -p " Press Enter to begin..." || true
507+ # Check if running interactively
508+ if [ -t 0 ]; then
509+ read -p " Press Enter to begin..." || true
510+ else
511+ cecho " yellow" " ⚠ Non-interactive mode detected - using defaults"
512+ sleep 2
513+ fi
497514 echo
498515
499516 # Run all setup steps
@@ -503,6 +520,8 @@ main() {
503520 configure_wifi
504521
505522 # --- Confirmation ---
523+ echo
524+ echo
506525 cecho " magenta" " ╔═════════════════════════════════════════════════════╗"
507526 cecho " magenta" " ║ INSTALLATION CONFIGURATION ║"
508527 cecho " magenta" " ╚═════════════════════════════════════════════════════╝"
@@ -515,7 +534,15 @@ main() {
515534 cecho " blue" " Installation will take 10-30 minutes depending on your Pi model."
516535 cecho " blue" " (Pi Zero 2 will be slower, Pi 4/5 will be faster)"
517536 echo
518- read -p " Press Enter to start installation, or Ctrl+C to cancel..." || true
537+ echo
538+ cecho " cyan" " ⏸ FINAL CONFIRMATION - PRESS ENTER TO CONTINUE ⏸"
539+ echo
540+ if [ -t 0 ]; then
541+ read -p " Press Enter to start installation, or Ctrl+C to cancel..." || true
542+ else
543+ cecho " yellow" " Auto-starting in 5 seconds (non-interactive mode)..."
544+ sleep 5
545+ fi
519546 echo
520547
521548 INSTALLATION_FAILED=1 # Mark that installation has started
@@ -721,54 +748,72 @@ main() {
721748 cecho " blue" " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
722749 cecho " blue" " Configuring Shairport-Sync..."
723750 cecho " blue" " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
724- log " Creating configuration file..."
725-
726- # Create optimized config
727- sudo tee /etc/shairport-sync.conf > /dev/null << EOF
728- // Generated by AirPlay 2 Installer v$SCRIPT_VERSION
729- // Installation date: $( date)
730- // Device: $audio_device_plug
731-
732- general = {
733- name = "$airplay_name ";
734- interpolation = "soxr";
735- output_backend = "alsa";
736- volume_max_db = 0.0;
737- volume_control_combined_hardware_priority = "yes";
738- };
739-
740- alsa = {
741- output_device = "$audio_device_plug ";
742- EOF
751+ log " Creating configuration file from sample..."
743752
744- # Only add mixer control if one was detected
745- if [ -n " $mixer_control " ]; then
746- sudo tee -a /etc/shairport-sync.conf > /dev/null << EOF
747- mixer_control_name = "$mixer_control ";
748- mixer_device = "hw:$card_number ";
749- EOF
753+ # Copy sample config as base (installed by make install)
754+ if [ -f /etc/shairport-sync.conf.sample ]; then
755+ sudo cp /etc/shairport-sync.conf.sample /etc/shairport-sync.conf
756+ log " Copied sample config to /etc/shairport-sync.conf"
757+ else
758+ cecho " yellow" " ⚠ Sample config not found, creating minimal config"
759+ # Fallback to minimal config if sample doesn't exist
760+ sudo tee /etc/shairport-sync.conf > /dev/null << 'FALLBACK_EOF '
761+ // Minimal configuration - sample file was not available
762+ general = {};
763+ alsa = {};
764+ FALLBACK_EOF
750765 fi
751766
752- sudo tee -a /etc/shairport-sync.conf > /dev/null << EOF
753- output_rate = "auto";
754- output_format = "S16";
755- disable_synchronization = "no";
756- period_size = 1024;
757- buffer_size = 8192;
758- };
767+ # Now edit the config file to set our values
768+ log " Configuring AirPlay name: $airplay_name "
759769
760- sessioncontrol = {
761- session_timeout = 20;
762- };
763- EOF
770+ # Set the AirPlay device name
771+ sudo sed -i ' /general =/,/^}/{ s|//[[:space:]]*name = .*| name = "' " $airplay_name " ' ";|; /^[[:space:]]*name = /d; /general =/a\ name = "' " $airplay_name " ' ";
772+ }' /etc/shairport-sync.conf
773+
774+ # Set output device
775+ log " Configuring audio output: $audio_device_plug "
776+ sudo sed -i ' /alsa =/,/^}/{
777+ s|//[[:space:]]*output_device = .*| output_device = "' " $audio_device_plug " ' ";|
778+ s|^[[:space:]]*output_device = .*| output_device = "' " $audio_device_plug " ' ";|
779+ }' /etc/shairport-sync.conf
780+
781+ # Set mixer control if available
782+ if [ -n " $mixer_control " ]; then
783+ log " Configuring mixer control: $mixer_control on hw:$card_number "
784+ sudo sed -i ' /alsa =/,/^}/{
785+ s|//[[:space:]]*mixer_control_name = .*| mixer_control_name = "' " $mixer_control " ' ";|
786+ s|^[[:space:]]*mixer_control_name = .*| mixer_control_name = "' " $mixer_control " ' ";|
787+ s|//[[:space:]]*mixer_device = .*| mixer_device = "hw:' " $card_number " ' ";|
788+ s|^[[:space:]]*mixer_device = .*| mixer_device = "hw:' " $card_number " ' ";|
789+ }' /etc/shairport-sync.conf
790+ fi
791+
792+ # Set output format
793+ sudo sed -i ' /alsa =/,/^}/{
794+ s|//[[:space:]]*output_rate = .*| output_rate = "auto";|
795+ s|^[[:space:]]*output_rate = .*| output_rate = "auto";|
796+ s|//[[:space:]]*output_format = .*| output_format = "S16";|
797+ s|^[[:space:]]*output_format = .*| output_format = "S16";|
798+ }' /etc/shairport-sync.conf
799+
800+ # Set volume settings
801+ sudo sed -i ' /general =/,/^}/{
802+ s|//[[:space:]]*volume_max_db = .*| volume_max_db = 4.0;|
803+ s|^[[:space:]]*volume_max_db = .*| volume_max_db = 4.0;|
804+ s|//[[:space:]]*default_airplay_volume = .*| default_airplay_volume = -6.0;|
805+ s|^[[:space:]]*default_airplay_volume = .*| default_airplay_volume = -6.0;|
806+ s|//[[:space:]]*high_volume_idle_timeout_in_minutes = .*| high_volume_idle_timeout_in_minutes = 1;|
807+ s|^[[:space:]]*high_volume_idle_timeout_in_minutes = .*| high_volume_idle_timeout_in_minutes = 1;|
808+ }' /etc/shairport-sync.conf
764809
765810 # Verify config file was created
766811 if [ ! -f /etc/shairport-sync.conf ]; then
767812 cecho " red" " ❌ Configuration file was not created"
768813 exit 1
769814 fi
770815
771- cecho " green" " ✓ Configuration file created"
816+ cecho " green" " ✓ Configuration file created and customized "
772817
773818 # Set mixer volume to maximum if available
774819 if [ -n " $mixer_control " ]; then
824869
825870 if ! check_service " shairport-sync" 5; then
826871 cecho " red" " ❌ Shairport-Sync service failed to start"
872+ cecho " yellow" " Checking service status..."
873+ sudo systemctl status shairport-sync --no-pager -l | tail -20
827874 exit 1
828875 fi
876+
877+ # Verify avahi-daemon is running (required for AirPlay discovery)
878+ cecho " blue" " Checking Avahi daemon (required for device discovery)..."
879+ if ! systemctl is-active --quiet avahi-daemon; then
880+ cecho " yellow" " ⚠ Avahi daemon is not running, attempting to start..."
881+ sudo systemctl start avahi-daemon
882+ sleep 2
883+ if systemctl is-active --quiet avahi-daemon; then
884+ cecho " green" " ✓ Avahi daemon started"
885+ else
886+ cecho " red" " ❌ Avahi daemon failed to start - AirPlay device may not be discoverable"
887+ fi
888+ else
889+ cecho " green" " ✓ Avahi daemon is running"
890+ fi
829891 echo
830892
831893 # --- Wi-Fi Power Management Instructions ---
0 commit comments