From 9878b9d68f8f9f148002ca6137b2b0b1ce91b1a9 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Feb 2024 19:30:42 +0700 Subject: [PATCH 01/19] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index f87a7865d..563b8fdba 100644 --- a/install.sh +++ b/install.sh @@ -4,7 +4,7 @@ alias=r1 . /srv/http/bash/settings/addons.sh -# 20240216 +# 20240218 [[ ! -e $dirshm/nosound && ! -e $dirshm/output ]] && restartmpd=1 [[ -e $dirsystem/btoutputall ]] && mv $dirsystem/{btoutputall,devicewithbt} From 095dcf0249b35d05c62cc866298224546eb05f22 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Feb 2024 19:33:48 +0700 Subject: [PATCH 02/19] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 563b8fdba..bf7ac5cf8 100644 --- a/install.sh +++ b/install.sh @@ -89,7 +89,7 @@ fi if [[ -e /usr/bin/camilladsp ]]; then rm -f $dirsystem/camilla.conf mkdir -p $dircamilladsp/raw - if [[ $( camilladsp -V ) != 'CamillaDSP 2.0.1' ]]; then + if [[ $( camilladsp -V ) != 'CamillaDSP 2.0.2' ]]; then systemctl stop camilladsp rm -f /etc/default/camilladsp /usr/lib/systemd/system/camilladsp.service pacman -Sy --noconfirm camilladsp From e200d503532d0a648088db0aaf539f393821b23c Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Feb 2024 21:38:34 +0700 Subject: [PATCH 03/19] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index bf7ac5cf8..db94724ed 100644 --- a/install.sh +++ b/install.sh @@ -118,5 +118,5 @@ cacheBust installfinish -# 20240216 +# 20240218 [[ $restartmpd ]] && $dirsettings/player-conf.sh From eaadfff9b63482db7e0b9fea27fde783fcd67ff5 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Feb 2024 21:47:27 +0700 Subject: [PATCH 04/19] u --- srv/http/bash/audiocd.sh | 3 +-- srv/http/bash/common.sh | 8 ++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/srv/http/bash/audiocd.sh b/srv/http/bash/audiocd.sh index 1dad3df7b..32ad80ddc 100644 --- a/srv/http/bash/audiocd.sh +++ b/srv/http/bash/audiocd.sh @@ -41,7 +41,6 @@ discid=${cddiscid[0]} trackL=${cddiscid[1]} # also = offset last index (offsets: +1 lead-in) cdData() { - notify audiocd 'Audio CD' "$artist • $album" offset=( ${cddiscid[@]:2} ) # offset - frame end offset[trackL]=$(( ${offset[trackL]} * 75 )) # last - seconds > frames 1:75 (( $( grep -c ' / ' <<< ${titles[@]} ) > 1 )) && va=1 # title=ARTIST / TITLE format more than 1 track @@ -136,7 +135,7 @@ fi # add tracks to playlist grep -q -m1 'audiocdplclear.*true' $dirsystem/display.json && mpc -q clear ! statePlay && trackcd=$(( $( mpc status %length% ) + 1 )) -notify audiocd 'Audio CD' 'Add to Playlist ...' +notify 'audiocd blink' 'Audio CD' 'Add to Playlist ...' for i in $( seq 1 $trackL ); do tracklist+="cdda:///$i " done diff --git a/srv/http/bash/common.sh b/srv/http/bash/common.sh index e7e1b2b12..5f7431357 100644 --- a/srv/http/bash/common.sh +++ b/srv/http/bash/common.sh @@ -244,13 +244,9 @@ mpcElapsed() { mpc status %currenttime% | awk -F: '{print ($1 * 60) + $2}' } notify() { # icon title message delayms - local blink data delay icon ip json message title + local data delay icon ip json message title [[ $1 == '-ip' ]] && ip=$2 && shift 2 - if [[ $4 ]]; then - delay=$4 - else - [[ ${1: -5} == 'blink' ]] && delay=-1 || delay=3000 - fi + [[ $4 ]] && delay=$4 || delay=3000 icon=$1 title=$( stringEscape $2 ) message=$( stringEscape $3 ) From 21d0f993446644c70d1f6d63e8f6b8daace1b371 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Feb 2024 22:01:11 +0700 Subject: [PATCH 05/19] u --- srv/http/bash/audiocd.sh | 3 ++- srv/http/bash/common.sh | 8 ++++++-- srv/http/bash/settings/player-asound.sh | 2 +- srv/http/bash/settings/player-conf.sh | 2 +- srv/http/bash/settings/player-devices.sh | 2 ++ 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/srv/http/bash/audiocd.sh b/srv/http/bash/audiocd.sh index 32ad80ddc..1dad3df7b 100644 --- a/srv/http/bash/audiocd.sh +++ b/srv/http/bash/audiocd.sh @@ -41,6 +41,7 @@ discid=${cddiscid[0]} trackL=${cddiscid[1]} # also = offset last index (offsets: +1 lead-in) cdData() { + notify audiocd 'Audio CD' "$artist • $album" offset=( ${cddiscid[@]:2} ) # offset - frame end offset[trackL]=$(( ${offset[trackL]} * 75 )) # last - seconds > frames 1:75 (( $( grep -c ' / ' <<< ${titles[@]} ) > 1 )) && va=1 # title=ARTIST / TITLE format more than 1 track @@ -135,7 +136,7 @@ fi # add tracks to playlist grep -q -m1 'audiocdplclear.*true' $dirsystem/display.json && mpc -q clear ! statePlay && trackcd=$(( $( mpc status %length% ) + 1 )) -notify 'audiocd blink' 'Audio CD' 'Add to Playlist ...' +notify audiocd 'Audio CD' 'Add to Playlist ...' for i in $( seq 1 $trackL ); do tracklist+="cdda:///$i " done diff --git a/srv/http/bash/common.sh b/srv/http/bash/common.sh index 5f7431357..e7e1b2b12 100644 --- a/srv/http/bash/common.sh +++ b/srv/http/bash/common.sh @@ -244,9 +244,13 @@ mpcElapsed() { mpc status %currenttime% | awk -F: '{print ($1 * 60) + $2}' } notify() { # icon title message delayms - local data delay icon ip json message title + local blink data delay icon ip json message title [[ $1 == '-ip' ]] && ip=$2 && shift 2 - [[ $4 ]] && delay=$4 || delay=3000 + if [[ $4 ]]; then + delay=$4 + else + [[ ${1: -5} == 'blink' ]] && delay=-1 || delay=3000 + fi icon=$1 title=$( stringEscape $2 ) message=$( stringEscape $3 ) diff --git a/srv/http/bash/settings/player-asound.sh b/srv/http/bash/settings/player-asound.sh index c0591a8ff..e85602cb8 100644 --- a/srv/http/bash/settings/player-asound.sh +++ b/srv/http/bash/settings/player-asound.sh @@ -4,7 +4,7 @@ ! type -t args2va &> /dev/null && . /srv/http/bash/common.sh -asoundcard=$( < $dirsystem/asoundcard ) +[[ ! $asoundcard ]] && asoundcard=$( < $dirsystem/asoundcard ) [[ ! $asoundcard ]] && asoundcard=0 if [[ $asoundcard != -1 ]]; then ######## diff --git a/srv/http/bash/settings/player-conf.sh b/srv/http/bash/settings/player-conf.sh index ba1a6729f..8aa4f9a77 100644 --- a/srv/http/bash/settings/player-conf.sh +++ b/srv/http/bash/settings/player-conf.sh @@ -55,7 +55,7 @@ $audiooutputbt " > $dirmpdconf/bluetooth.conf ######## fi -asoundcard=$( < $dirsystem/asoundcard ) +[[ ! $asoundcard ]] && asoundcard=$( < $dirsystem/asoundcard ) if [[ $asoundcard == -1 ]]; then # no audio devices rm -f $dirmpdconf/{output,soxr}.conf if [[ $usbdac == remove ]]; then diff --git a/srv/http/bash/settings/player-devices.sh b/srv/http/bash/settings/player-devices.sh index e898cde9c..96b7ece61 100644 --- a/srv/http/bash/settings/player-devices.sh +++ b/srv/http/bash/settings/player-devices.sh @@ -17,6 +17,7 @@ audioaplayname=$( getContent $dirsystem/audio-aplayname 'bcm2835 Headphones' ) audiooutput=$( getContent $dirsystem/audio-output 'On-board Headphones' ) +[[ ! $proccards ]] && readarray -t proccards <<< $( sed -n '/]:/ {s/^.* - //; p}' /proc/asound/cards ) for aplayname in "${proccards[@]}"; do [[ ${aplayname:0:8} == snd_rpi_ ]] && aplayname=$( tr _ - <<< ${aplayname:8} ) # snd_rpi_xxx_yyy > xxx-yyy [[ $aplayname == wsp || $aplayname == RPi-Cirrus ]] && aplayname=cirrus-wm5102 @@ -86,3 +87,4 @@ card='$card' device='$device' hwmixer='$hwmixer' mixertype='$mixertype > $dirshm/output +asoundcard=$card From 39c45d2ca8c3a25daf57b8eba247e782acd693b7 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Feb 2024 22:35:55 +0700 Subject: [PATCH 06/19] u --- srv/http/assets/js/player.js | 2 -- srv/http/bash/settings/player-devices.sh | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/srv/http/assets/js/player.js b/srv/http/assets/js/player.js index 8e70f3b90..71cedd91f 100644 --- a/srv/http/assets/js/player.js +++ b/srv/http/assets/js/player.js @@ -1,4 +1,3 @@ -var typelist = { 'None / 0dB': 'none', 'Mixer device': 'hardware', 'MPD software': 'software' } var warning = iconwarning +'Lower speakers / headphones volume

' +'Signal will be set to original level at 0dB.
' +'Beware of too high volume.
'; @@ -338,7 +337,6 @@ function renderPage() { $( '#divhwmixer' ).removeClass( 'hide' ); } else { $( '#divhwmixer' ).addClass( 'hide' ); - delete typelist[ 'Mixer device' ]; } $( '#setting-hwmixer' ).toggleClass( 'hide', ! S.volume ); $( '#divmixertype' ).toggleClass( 'hide', S.camilladsp ); diff --git a/srv/http/bash/settings/player-devices.sh b/srv/http/bash/settings/player-devices.sh index 96b7ece61..f662a6ede 100644 --- a/srv/http/bash/settings/player-devices.sh +++ b/srv/http/bash/settings/player-devices.sh @@ -13,11 +13,13 @@ ### included by player-conf.sh +[[ -e $dirshm/output ]] && rm -f $dirshm/{amixercontrol,listdevice,listmixer,nosound,output} # in player-conf.sh +[[ ! $proccards ]] && readarray -t proccards <<< $( sed -n '/]:/ {s/^.* - //; p}' /proc/asound/cards ) # in player-conf.sh + ! type -t args2va &> /dev/null && . /srv/http/bash/common.sh audioaplayname=$( getContent $dirsystem/audio-aplayname 'bcm2835 Headphones' ) audiooutput=$( getContent $dirsystem/audio-output 'On-board Headphones' ) -[[ ! $proccards ]] && readarray -t proccards <<< $( sed -n '/]:/ {s/^.* - //; p}' /proc/asound/cards ) for aplayname in "${proccards[@]}"; do [[ ${aplayname:0:8} == snd_rpi_ ]] && aplayname=$( tr _ - <<< ${aplayname:8} ) # snd_rpi_xxx_yyy > xxx-yyy [[ $aplayname == wsp || $aplayname == RPi-Cirrus ]] && aplayname=cirrus-wm5102 @@ -43,7 +45,7 @@ aplayname=${cnd[1]} device=${cnd[2]} [[ $usbdac == add ]] && name=$aplayname || name=$audiooutput -if [[ $aplayname != cirrus-wm5102 ]]; then +if [[ ! $listmixer ]]; then # ! cirrus-wm5102 amixer=$( amixer -c $card scontents ) if [[ $amixer ]]; then amixer=$( grep -A1 ^Simple <<< $amixer \ From e0310b978d3af42ce0b040d22bdb4c961839bbf1 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Feb 2024 09:53:00 +0700 Subject: [PATCH 07/19] u --- srv/http/assets/js/player.js | 5 +- srv/http/bash/common.sh | 7 +-- srv/http/bash/settings/player-asound.sh | 7 +-- srv/http/bash/settings/player-conf.sh | 14 ++--- srv/http/bash/settings/player-devices.sh | 70 +++++++++++------------- 5 files changed, 47 insertions(+), 56 deletions(-) diff --git a/srv/http/assets/js/player.js b/srv/http/assets/js/player.js index 71cedd91f..77fa65d24 100644 --- a/srv/http/assets/js/player.js +++ b/srv/http/assets/js/player.js @@ -75,9 +75,8 @@ $( '#mixertype' ).on( 'click', function() { $( '#setting-mixertype' ).on( 'click', function() { info( { icon : SW.icon - , title : SW.title - , message : 'Type:' - , list : [ '', 'radio', { kv: { 'Mixer device (hardware)': 'hardware', 'MPD software': 'software' }, sameline: false } ] + , title : 'Volume Type' + , list : [ '', 'radio', { kv: { 'DAC hardware (Mixer Device)': 'hardware', 'MPD software': 'software' }, sameline: false } ] , values : S.mixertype ? S.output.mixertype : 'hardware' , cancel : switchCancel , ok : () => setMixerType( infoVal() ) diff --git a/srv/http/bash/common.sh b/srv/http/bash/common.sh index e7e1b2b12..1636b5d6a 100644 --- a/srv/http/bash/common.sh +++ b/srv/http/bash/common.sh @@ -123,10 +123,9 @@ conf2json() { v=${l/*=} [[ ! $v ]] && v=false v=$( sed -E -e "s/^[\"']|[\"']$//g" \ - -e 's/^True$|^False$/\L&/ - s/^yes$/true/ - s/^no$/false/' <<< $v ) - confNotString "$v" || v='"'$( stringEscape $v )'"' # quote and escape string + -e 's/^True$|^yes$/true/ + s/^False$|^no$/false/' <<< $v ) + confNotString "$v" || v='"'$( stringEscape "$v" )'"' # quote and escape string [[ ! $nocap ]] && k=${k^^} json+=', "'$k'": '$v done diff --git a/srv/http/bash/settings/player-asound.sh b/srv/http/bash/settings/player-asound.sh index e85602cb8..59debc802 100644 --- a/srv/http/bash/settings/player-asound.sh +++ b/srv/http/bash/settings/player-asound.sh @@ -1,10 +1,9 @@ #!/bin/bash -### included by < player-conf.sh +### included by <<< player-conf.sh +! type -t args2va &> /dev/null && . /srv/http/bash/common.sh # if run directly +[[ ! $asoundcard ]] && asoundcard=$( < $dirsystem/asoundcard ) # if run directly -! type -t args2va &> /dev/null && . /srv/http/bash/common.sh - -[[ ! $asoundcard ]] && asoundcard=$( < $dirsystem/asoundcard ) [[ ! $asoundcard ]] && asoundcard=0 if [[ $asoundcard != -1 ]]; then ######## diff --git a/srv/http/bash/settings/player-conf.sh b/srv/http/bash/settings/player-conf.sh index 8aa4f9a77..4dc9630fb 100644 --- a/srv/http/bash/settings/player-conf.sh +++ b/srv/http/bash/settings/player-conf.sh @@ -12,20 +12,20 @@ usbdac=$1 rm -f $dirmpdconf/{bluetooth,camilladsp,fifo}.conf -[[ -e /usr/bin/camilladsp ]] && systemctl stop camilladsp -rm -f $dirshm/{amixercontrol,listdevice,listmixer,nosound,output} readarray -t proccards <<< $( sed -n '/]:/ {s/^.* - //; p}' /proc/asound/cards ) if [[ $proccards ]]; then - . $dirsettings/player-devices.sh + rm -f $dirshm/nosound + . $dirsettings/player-devices.sh # >>> $asoundcard else - [[ -e $dirshm/btreceiver ]] && card=0 || card=-1 - echo $card > $dirsystem/asoundcard touch $dirshm/nosound + rm -f $dirshm/{amixercontrol,listdevice,listmixer,output} + [[ -e $dirshm/btreceiver ]] && asoundcard=0 || asoundcard=-1 + echo $asoundcard > $dirsystem/asoundcard pushData display '{ "volumenone": true }' fi -. $dirsettings/player-asound.sh # $bluetooth, $camilladsp, $equalizer +. $dirsettings/player-asound.sh # >>> $bluetooth, $camilladsp, $equalizer pushStatus() { $dirbash/status-push.sh @@ -55,7 +55,6 @@ $audiooutputbt " > $dirmpdconf/bluetooth.conf ######## fi -[[ ! $asoundcard ]] && asoundcard=$( < $dirsystem/asoundcard ) if [[ $asoundcard == -1 ]]; then # no audio devices rm -f $dirmpdconf/{output,soxr}.conf if [[ $usbdac == remove ]]; then @@ -74,6 +73,7 @@ elif [[ ! $btoutputonly ]]; then outputswitch=$name fi if [[ $camilladsp ]]; then + systemctl stop camilladsp hw=hw:Loopback,1 ln -sf $dirmpdconf/{conf/,}camilladsp.conf elif [[ $equalizer ]]; then diff --git a/srv/http/bash/settings/player-devices.sh b/srv/http/bash/settings/player-devices.sh index f662a6ede..07dbf5b42 100644 --- a/srv/http/bash/settings/player-devices.sh +++ b/srv/http/bash/settings/player-devices.sh @@ -11,12 +11,9 @@ # - set as hardware if mixer device available # - if nothing, set as software -### included by player-conf.sh - -[[ -e $dirshm/output ]] && rm -f $dirshm/{amixercontrol,listdevice,listmixer,nosound,output} # in player-conf.sh -[[ ! $proccards ]] && readarray -t proccards <<< $( sed -n '/]:/ {s/^.* - //; p}' /proc/asound/cards ) # in player-conf.sh - -! type -t args2va &> /dev/null && . /srv/http/bash/common.sh +### included by <<< player-conf.sh +! type -t args2va &> /dev/null && . /srv/http/bash/common.sh # if run directly +[[ ! $proccards ]] && readarray -t proccards <<< $( sed -n '/]:/ {s/^.* - //; p}' /proc/asound/cards ) # if run directly audioaplayname=$( getContent $dirsystem/audio-aplayname 'bcm2835 Headphones' ) audiooutput=$( getContent $dirsystem/audio-output 'On-board Headphones' ) @@ -24,29 +21,27 @@ for aplayname in "${proccards[@]}"; do [[ ${aplayname:0:8} == snd_rpi_ ]] && aplayname=$( tr _ - <<< ${aplayname:8} ) # snd_rpi_xxx_yyy > xxx-yyy [[ $aplayname == wsp || $aplayname == RPi-Cirrus ]] && aplayname=cirrus-wm5102 [[ $aplayname == $audioaplayname ]] && name=$audiooutput || name=${aplayname/bcm2835/On-board} - listdevice+=', "'$name'": "'$aplayname'"' + LISTDEVICE+=', "'$name'": "'$aplayname'"' done -######## -echo "{ ${listdevice:1} }" > $dirshm/listdevice aplayl=$( aplay -l 2> /dev/null | awk '/^card/ && !/Loopback/' ) if [[ $usbdac == add ]]; then aplaycard=$( tail -1 <<< $aplayl ) elif [[ $aplayname == cirrus-wm5102 ]]; then aplaycard=$( grep -m1 wm5102 <<< $aplayl ) - hwmixer='HPOUT2 Digital' - listmixer='[ "HPOUT1 Digital", "HPOUT2 Digital", "SPDIF Out", "Speaker Digital" ]' + HWMIXER='HPOUT2 Digital' + LISTMIXER=", 'HPOUT1 Digital', 'HPOUT2 Digital', 'SPDIF Out', 'Speaker Digital'" else aplaycard=$( grep -m1 "$audioaplayname" <<< $aplayl ) # avoid duplicate aplayname fi readarray -t cnd <<< $( sed -E 's/card (.*):.*\[(.*)], device (.*):.*/\1\n\2\n\3/' <<< "$aplaycard" ) -card=${cnd[0]} -aplayname=${cnd[1]} -device=${cnd[2]} -[[ $usbdac == add ]] && name=$aplayname || name=$audiooutput +CARD=${cnd[0]} +APLAYNAME=${cnd[1]} +DEVICE=${cnd[2]} +[[ $usbdac == add ]] && NAME=$APLAYNAME || NAME=$audiooutput -if [[ ! $listmixer ]]; then # ! cirrus-wm5102 - amixer=$( amixer -c $card scontents ) +if [[ ! $LISTMIXER ]]; then # ! cirrus-wm5102 + amixer=$( amixer -c $CARD scontents ) if [[ $amixer ]]; then amixer=$( grep -A1 ^Simple <<< $amixer \ | sed 's/^\s*Cap.*: /^/' \ @@ -58,35 +53,34 @@ if [[ ! $listmixer ]]; then # ! cirrus-wm5102 if [[ $controls ]]; then readarray -t controls <<< $( cut -d"'" -f2 <<< $controls | sort -u ) for control in "${controls[@]}"; do - listmixer+=', "'$control'"' - [[ $control == Digital ]] && hwmixer=Digital + LISTMIXER+=', "'$control'"' + [[ $control == Digital ]] && HWMIXER=Digital done - listmixer="[ ${listmixer:1} ]" - hwmixerfile="$dirsystem/hwmixer-$aplayname" + hwmixerfile="$dirsystem/hwmixer-$APLAYNAME" if [[ -e $hwmixerfile ]]; then # manual - hwmixer=$( < "$hwmixerfile" ) - elif [[ ! $hwmixer ]]; then # not Digital - hwmixer=${controls[0]} + HWMIXER=$( < "$hwmixerfile" ) + elif [[ ! $HWMIXER ]]; then # not Digital + HWMIXER=${controls[0]} fi fi fi fi -mixertypefile="$dirsystem/mixertype-$aplayname" +mixertypefile="$dirsystem/mixertype-$APLAYNAME" if [[ -e $mixertypefile ]]; then - mixertype=$( < "$mixertypefile" ) + MIXERTYPE=$( < "$mixertypefile" ) else - [[ $listmixer ]] && mixertype=hardware || mixertype=none + [[ $LISTMIXER ]] && MIXERTYPE=hardware || MIXERTYPE=none fi -######## -echo $card > $dirsystem/asoundcard -[[ $hwmixer ]] && echo "$hwmixer" > $dirshm/amixercontrol # quote to includes trailing space (if any) -[[ $listmixer ]] && echo $listmixer > $dirshm/listmixer +[[ $HWMIXER ]] && echo "$HWMIXER" > $dirshm/amixercontrol || rm -f $dirshm/amixercontrol +[[ $LISTDEVICE ]] && echo "{ ${LISTDEVICE:1} }" > $dirshm/listdevice || rm -f $dirshm/listdevice +[[ $LISTMIXER ]] && echo "[ ${LISTMIXER:1} ]" > $dirshm/listmixer || rm -f $dirshm/listmixer echo ' -aplayname="'$aplayname'" -name="'$name'" -card='$card' -device='$device' -hwmixer='$hwmixer' -mixertype='$mixertype > $dirshm/output -asoundcard=$card +aplayname="'$APLAYNAME'" +name="'$NAME'" +card='$CARD' +device='$DEVICE' +hwmixer='$HWMIXER' +mixertype='$MIXERTYPE > $dirshm/output +echo $CARD > $dirsystem/asoundcard +asoundcard=$CARD From a8332dd4a089406a084ed81bddf2fe0927b556d7 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Feb 2024 10:00:16 +0700 Subject: [PATCH 08/19] u --- srv/http/bash/settings/player-asound.sh | 3 +-- srv/http/bash/settings/player-devices.sh | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/srv/http/bash/settings/player-asound.sh b/srv/http/bash/settings/player-asound.sh index 59debc802..f7f2f198c 100644 --- a/srv/http/bash/settings/player-asound.sh +++ b/srv/http/bash/settings/player-asound.sh @@ -4,8 +4,7 @@ ! type -t args2va &> /dev/null && . /srv/http/bash/common.sh # if run directly [[ ! $asoundcard ]] && asoundcard=$( < $dirsystem/asoundcard ) # if run directly -[[ ! $asoundcard ]] && asoundcard=0 -if [[ $asoundcard != -1 ]]; then +if [[ $asoundcard != -1 ]]; then # <<< player-devices.sh ######## asound="\ defaults.pcm.card $asoundcard diff --git a/srv/http/bash/settings/player-devices.sh b/srv/http/bash/settings/player-devices.sh index 07dbf5b42..bc102667f 100644 --- a/srv/http/bash/settings/player-devices.sh +++ b/srv/http/bash/settings/player-devices.sh @@ -17,7 +17,7 @@ audioaplayname=$( getContent $dirsystem/audio-aplayname 'bcm2835 Headphones' ) audiooutput=$( getContent $dirsystem/audio-output 'On-board Headphones' ) -for aplayname in "${proccards[@]}"; do +for aplayname in "${proccards[@]}"; do # <<< player-conf.sh [[ ${aplayname:0:8} == snd_rpi_ ]] && aplayname=$( tr _ - <<< ${aplayname:8} ) # snd_rpi_xxx_yyy > xxx-yyy [[ $aplayname == wsp || $aplayname == RPi-Cirrus ]] && aplayname=cirrus-wm5102 [[ $aplayname == $audioaplayname ]] && name=$audiooutput || name=${aplayname/bcm2835/On-board} @@ -25,7 +25,7 @@ for aplayname in "${proccards[@]}"; do done aplayl=$( aplay -l 2> /dev/null | awk '/^card/ && !/Loopback/' ) -if [[ $usbdac == add ]]; then +if [[ $usbdac == add ]]; then # <<< player-conf.sh aplaycard=$( tail -1 <<< $aplayl ) elif [[ $aplayname == cirrus-wm5102 ]]; then aplaycard=$( grep -m1 wm5102 <<< $aplayl ) @@ -80,7 +80,7 @@ aplayname="'$APLAYNAME'" name="'$NAME'" card='$CARD' device='$DEVICE' -hwmixer='$HWMIXER' +hwmixer="'$HWMIXER'" mixertype='$MIXERTYPE > $dirshm/output echo $CARD > $dirsystem/asoundcard asoundcard=$CARD From 66acb9d48ec64e0d24ac878bffed0878e673b5f9 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Feb 2024 12:11:50 +0700 Subject: [PATCH 09/19] u --- install.sh | 15 ++++++++--- srv/http/assets/css/common.css | 4 +-- srv/http/assets/js/player.js | 32 ++++++++++++------------ srv/http/bash/settings/player-asound.sh | 7 +++--- srv/http/bash/settings/player-conf.sh | 18 ++++++------- srv/http/bash/settings/player-devices.sh | 20 +++++++-------- srv/http/bash/settings/player.sh | 20 +++++++-------- srv/http/settings.php | 8 ++++-- srv/http/settings/camilla.php | 2 +- srv/http/settings/player.php | 16 ++++++------ srv/http/settings/system.php | 2 +- 11 files changed, 78 insertions(+), 66 deletions(-) diff --git a/install.sh b/install.sh index db94724ed..7d95d3edc 100644 --- a/install.sh +++ b/install.sh @@ -4,8 +4,17 @@ alias=r1 . /srv/http/bash/settings/addons.sh -# 20240218 -[[ ! -e $dirshm/nosound && ! -e $dirshm/output ]] && restartmpd=1 +# 20240219 +readarray -t mixerfiles <<< $( ls $dirsystem/hwmixer-* 2> /dev/null ) +if [[ $mixerfiles ]]; then + for f in "${mixerfiles[@]}"; do + mv "$f" "${f/hwmixer-/mixer-}" + done +fi + +if [[ ! -e $dirshm/nosound ]]; then + ( [[ ! -e $dirshm/output ]] || grep -q ^hwmixer $dirshm/output ) && restartmpd=1 +fi [[ -e $dirsystem/btoutputall ]] && mv $dirsystem/{btoutputall,devicewithbt} @@ -118,5 +127,5 @@ cacheBust installfinish -# 20240218 +# 20240219 [[ $restartmpd ]] && $dirsettings/player-conf.sh diff --git a/srv/http/assets/css/common.css b/srv/http/assets/css/common.css index 0b8f2d22a..e65adb631 100644 --- a/srv/http/assets/css/common.css +++ b/srv/http/assets/css/common.css @@ -10,7 +10,7 @@ @font-face { font-family : rern; - src : url( '/assets/fonts/rern.woff2?v=1707808685' ); + src : url( '/assets/fonts/rern.woff2?v=1708267847' ); } @font-face { font-family : Lato; @@ -232,7 +232,7 @@ i { .i-wifi2::before { content: '\F59A'; position: absolute; } .i-wifi2::after { content: '\F59B'; color: var( --cga ); } .i-wlan::before { content: '\F597' } -#divhwmixer .i-gear::before { content: '\F516' } +#divmixer .i-gear::before { content: '\F516' } html { height : 100%; diff --git a/srv/http/assets/js/player.js b/srv/http/assets/js/player.js index 77fa65d24..e986c72d8 100644 --- a/srv/http/assets/js/player.js +++ b/srv/http/assets/js/player.js @@ -4,18 +4,18 @@ var warning = iconwarning +'Lower speakers / headphones volume

' $( function() { // document ready start >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -$( '#audiooutput' ).on( 'input', function() { +$( '#device' ).on( 'input', function() { var $this = $( this ); var aplayname = $this.val(); var output = $this.find( 'option:selected' ).text() notify( 'volume', 'Audio Output Device', 'Change ...' ); - bash( [ 'audiooutput', output, aplayname, 'CMD OUTPUT APLAYNAME' ] ); + bash( [ 'device', output, aplayname, 'CMD OUTPUT APLAYNAME' ] ); } ); -$( '#hwmixer' ).on( 'input', function() { +$( '#mixer' ).on( 'input', function() { notify( 'volume', 'Hardware Mixer', 'Change ...' ); - bash( [ 'hwmixer', $( this ).val(), 'CMD HWMIXER' ] ); + bash( [ 'mixer', $( this ).val(), 'CMD MIXER' ] ); } ); -$( '#setting-hwmixer, #setting-bluealsa' ).on( 'click', function() { +$( '#setting-mixer, #setting-bluealsa' ).on( 'click', function() { if ( this.id.slice( -1 ) === 'a' ) { var cmd = 'volumebt'; var cmd0db = 'volume0dbbt'; @@ -23,7 +23,7 @@ $( '#setting-hwmixer, #setting-bluealsa' ).on( 'click', function() { } else { var cmd = 'volume'; var cmd0db = 'volume0db'; - var control = S.output.hwmixer; + var control = S.output.mixer; } info( { icon : SW.icon @@ -315,29 +315,29 @@ function renderPage() { if ( icondsp ) $( '#divbluealsa .col-l' ).append( icondsp ); $( '#divbluealsa' ).removeClass( 'hide' ); $( '#btaplayname' ).html( '' ); - $( '#divaudiooutput, #divhwmixer, #divmixertype' ).toggleClass( 'hide', ! S.devicewithbt ); + $( '#divdevice, #divmixer, #divmixertype' ).toggleClass( 'hide', ! S.devicewithbt ); } else { if ( icondsp ) $( '#divbluealsa .col-l' ).append( icondsp ); - $( '#divaudiooutput .col-l' ).html( $( '#divaudiooutput .col-l' ).html() + icondsp ); + $( '#divdevice .col-l' ).html( $( '#divdevice .col-l' ).html() + icondsp ); $( '#divbluealsa' ).addClass( 'hide' ); - $( '#divaudiooutput, #divhwmixer, #divmixertype' ).removeClass( 'hide' ); + $( '#divdevice, #divmixer, #divmixertype' ).removeClass( 'hide' ); } if ( S.asoundcard === -1 ) { $( '#divoutput, #divbitperfect, #divvolume' ).addClass( 'hide' ); } else { $( '#divoutput, #divbitperfect, #divvolume' ).removeClass( 'hide' ); - $( '#audiooutput' ) + $( '#device' ) .html( htmlOption( S.listdevice ) ) .val( S.output.aplayname ); if ( S.listmixer ) { - $( '#hwmixer' ) + $( '#mixer' ) .html( htmlOption( S.listmixer ) ) - .val( S.output.hwmixer ); - $( '#divhwmixer' ).removeClass( 'hide' ); + .val( S.output.mixer ); + $( '#divmixer' ).removeClass( 'hide' ); } else { - $( '#divhwmixer' ).addClass( 'hide' ); + $( '#divmixer' ).addClass( 'hide' ); } - $( '#setting-hwmixer' ).toggleClass( 'hide', ! S.volume ); + $( '#setting-mixer' ).toggleClass( 'hide', ! S.volume ); $( '#divmixertype' ).toggleClass( 'hide', S.camilladsp ); $( '#setting-mixertype' ).toggleClass( 'hide', ! S.listmixer || ! S.mixertype ); $( '#divdevicewithbt' ).toggleClass( 'hide', ! S.bluetooth ); @@ -347,7 +347,7 @@ function renderPage() { } $.each( S.lists, ( k, v ) => $( '#divlists .subhead[data-status="'+ k +'"]' ).toggleClass( 'hide', ! v ) ); $( '#divlists' ).toggleClass( 'hide', ! Object.values( S.lists ).includes( true ) ); - if ( I.range ) $( '#setting-'+ ( S.btaplayname ? 'bluealsa' : 'hwmixer' ) ).trigger( 'click' ); + if ( I.range ) $( '#setting-'+ ( S.btaplayname ? 'bluealsa' : 'mixer' ) ).trigger( 'click' ); showContent(); } function renderStatus() { diff --git a/srv/http/bash/settings/player-asound.sh b/srv/http/bash/settings/player-asound.sh index f7f2f198c..ecd603d23 100644 --- a/srv/http/bash/settings/player-asound.sh +++ b/srv/http/bash/settings/player-asound.sh @@ -91,10 +91,9 @@ echo "$asound" > /etc/asound.conf alsactl nrestore &> /dev/null # notify changes to running daemons # ---------------------------------------------------------------------------- -wm5102card=$( aplay -l 2> /dev/null | grep snd_rpi_wsp | cut -c 6 ) -if [[ $wm5102card ]]; then - output=$( getContent $dirsystem/hwmixer-wsp 'HPOUT2 Digital' ) - $dirsettings/player-wm5102.sh $wm5102card "$output" +if [[ $( getContent $dirsystem/audio-aplayname ) == cirrus-wm5102 ]]; then + output=$( getContent $dirsystem/mixer-cirrus-wm5102 'HPOUT2 Digital' ) + $dirsettings/player-wm5102.sh $asoundcard "$output" fi if [[ $camilladsp ]]; then diff --git a/srv/http/bash/settings/player-conf.sh b/srv/http/bash/settings/player-conf.sh index 4dc9630fb..ba9435d80 100644 --- a/srv/http/bash/settings/player-conf.sh +++ b/srv/http/bash/settings/player-conf.sh @@ -3,8 +3,8 @@ # output: # - get devices data - player-devices.sh # - set asound.conf - player-asound.sh -# - mixer_type - from file if manually set | hardware if hwmixer | software -# - mixer_control - from file if manually set | hwmixer | null +# - mixer_type - from file if manually set | hardware if mixer | software +# - mixer_control - from file if manually set | mixer | null # - mixer_device - card index . /srv/http/bash/common.sh @@ -63,7 +63,7 @@ if [[ $asoundcard == -1 ]]; then # no audio devices outputswitch='(None)' fi elif [[ ! $btoutputonly ]]; then - . $dirshm/output # aplayname name card device hwmixer mixertype + . $dirshm/output # aplayname name card device mixer mixertype # usbdac.rules if [[ $usbdac ]]; then $dirbash/cmd.sh playerstop @@ -99,7 +99,7 @@ elif [[ ! $btoutputonly ]]; then mixer_type "'$mixertype'"' if [[ $mixertype == hardware ]]; then # mixer_device must be card index audiooutput+=' - mixer_control "'$hwmixer'" + mixer_control "'$mixer'" mixer_device "hw:'$card'"' [[ -e $dirmpdconf/replaygain.conf && -e $dirsystem/replaygain-hw ]] && \ audiooutput+=' @@ -156,7 +156,7 @@ done [[ $asoundcard == -1 ]] && pushStatus && exit # >>>>>>>>>> # renderers ---------------------------------------------------------------------------- -[[ $hwmixer && ! $bluetooth && ! $camilladsp && ! $equalizer ]] && mixer=1 +[[ ! $mixer || $bluetooth || $camilladsp || $equalizer ]] && mixerno=1 if [[ -e /usr/bin/shairport-sync ]]; then ######## @@ -164,9 +164,9 @@ if [[ -e /usr/bin/shairport-sync ]]; then conf+=' alsa = { output_device = "'$hw'"; - mixer_control_name = "'$hwmixer'"; + mixer_control_name = "'$mixer'"; }' - [[ ! $mixer ]] && conf=$( grep -v mixer_control_name <<< $conf ) + [[ $mixerno ]] && conf=$( grep -v mixer_control_name <<< $conf ) #------- echo "$conf" > /etc/shairport-sync.conf systemctl try-restart shairport-sync @@ -186,8 +186,8 @@ if [[ -e /usr/bin/spotifyd ]]; then # hw:N (or default:CARD=xxxx) conf+=' device = "'$hw'" control = "'$hw'" -mixer = "'$hwmixer'"' - [[ ! $mixer ]] && conf=$( grep -v ^mixer <<< $conf ) +mixer = "'$mixer'"' + [[ $mixerno ]] && conf=$( grep -v ^mixer <<< $conf ) fi #------- echo "$conf" > /etc/spotifyd.conf diff --git a/srv/http/bash/settings/player-devices.sh b/srv/http/bash/settings/player-devices.sh index bc102667f..e8e381b4d 100644 --- a/srv/http/bash/settings/player-devices.sh +++ b/srv/http/bash/settings/player-devices.sh @@ -24,12 +24,12 @@ for aplayname in "${proccards[@]}"; do # <<< player-conf.sh LISTDEVICE+=', "'$name'": "'$aplayname'"' done -aplayl=$( aplay -l 2> /dev/null | awk '/^card/ && !/Loopback/' ) +aplayl=$( aplay -l | awk '/^card/ && !/Loopback/' ) if [[ $usbdac == add ]]; then # <<< player-conf.sh aplaycard=$( tail -1 <<< $aplayl ) elif [[ $aplayname == cirrus-wm5102 ]]; then aplaycard=$( grep -m1 wm5102 <<< $aplayl ) - HWMIXER='HPOUT2 Digital' + MIXER='HPOUT2 Digital' LISTMIXER=", 'HPOUT1 Digital', 'HPOUT2 Digital', 'SPDIF Out', 'Speaker Digital'" else aplaycard=$( grep -m1 "$audioaplayname" <<< $aplayl ) # avoid duplicate aplayname @@ -54,13 +54,13 @@ if [[ ! $LISTMIXER ]]; then # ! cirrus-wm5102 readarray -t controls <<< $( cut -d"'" -f2 <<< $controls | sort -u ) for control in "${controls[@]}"; do LISTMIXER+=', "'$control'"' - [[ $control == Digital ]] && HWMIXER=Digital + [[ $control == Digital ]] && MIXER=Digital done - hwmixerfile="$dirsystem/hwmixer-$APLAYNAME" - if [[ -e $hwmixerfile ]]; then # manual - HWMIXER=$( < "$hwmixerfile" ) - elif [[ ! $HWMIXER ]]; then # not Digital - HWMIXER=${controls[0]} + mixerfile="$dirsystem/mixer-$APLAYNAME" + if [[ -e $mixerfile ]]; then # manual + MIXER=$( < "$mixerfile" ) + elif [[ ! $MIXER ]]; then # not Digital + MIXER=${controls[0]} fi fi fi @@ -72,7 +72,7 @@ else [[ $LISTMIXER ]] && MIXERTYPE=hardware || MIXERTYPE=none fi -[[ $HWMIXER ]] && echo "$HWMIXER" > $dirshm/amixercontrol || rm -f $dirshm/amixercontrol +[[ $MIXER ]] && echo "$MIXER" > $dirshm/amixercontrol || rm -f $dirshm/amixercontrol [[ $LISTDEVICE ]] && echo "{ ${LISTDEVICE:1} }" > $dirshm/listdevice || rm -f $dirshm/listdevice [[ $LISTMIXER ]] && echo "[ ${LISTMIXER:1} ]" > $dirshm/listmixer || rm -f $dirshm/listmixer echo ' @@ -80,7 +80,7 @@ aplayname="'$APLAYNAME'" name="'$NAME'" card='$CARD' device='$DEVICE' -hwmixer="'$HWMIXER'" +mixer="'$MIXER'" mixertype='$MIXERTYPE > $dirshm/output echo $CARD > $dirsystem/asoundcard asoundcard=$CARD diff --git a/srv/http/bash/settings/player.sh b/srv/http/bash/settings/player.sh index 8b9da2a6a..21475a7b9 100644 --- a/srv/http/bash/settings/player.sh +++ b/srv/http/bash/settings/player.sh @@ -10,11 +10,6 @@ linkConf() { case $CMD in -audiooutput ) - echo $APLAYNAME > $dirsystem/audio-aplayname - echo $OUTPUT > $dirsystem/audio-output - $dirsettings/player-conf.sh - ;; autoupdate | ffmpeg | normalization ) [[ $ON ]] && linkConf || rm $dirmpdconf/$CMD.conf systemctl restart mpd @@ -70,6 +65,11 @@ custom ) $dirsettings/player-conf.sh fi ;; +device ) + echo $APLAYNAME > $dirsystem/audio-aplayname + echo $OUTPUT > $dirsystem/audio-output + $dirsettings/player-conf.sh + ;; devicewithbt ) enableFlagSet [[ -e $dirmpdconf/bluetooth.conf ]] && bluetooth=1 @@ -101,9 +101,9 @@ filetype ) done echo "${list:0:-4}" ;; -hwmixer ) +mixer ) aplayname=$( getVar aplayname $dirshm/output ) - echo $HWMIXER > "$dirsystem/hwmixer-$aplayname" + echo $MIXER > "$dirsystem/mixer-$aplayname" $dirsettings/player-conf.sh ;; mixertype ) @@ -116,9 +116,9 @@ mixertype ) else rm -f $dirsystem/replaygain-hw fi - if [[ $hwmixer ]]; then + if [[ $mixer ]]; then [[ $MIXERTYPE == hardware ]] && vol=$( mpc status %volume% ) || vol=0dB # [hw] set to current [sw] || [sw/none] set 0dB - amixer -c $card -Mq sset "$hwmixer" $vol + amixer -c $card -Mq sset "$mixer" $vol fi $dirsettings/player-conf.sh [[ $MIXERTYPE == none ]] && volumenone=true || volumenone=false @@ -126,7 +126,7 @@ mixertype ) ;; novolume ) . $dirshm/output - amixer -c $card -Mq sset "$hwmixer" 0dB + amixer -c $card -Mq sset "$mixer" 0dB echo none > "$dirsystem/mixertype-$aplayname" mpc -q crossfade 0 rm -f $dirmpdconf/{normalization,replaygain,soxr}.conf diff --git a/srv/http/settings.php b/srv/http/settings.php index 3437175f4..5336485c3 100644 --- a/srv/http/settings.php +++ b/srv/http/settings.php @@ -95,7 +95,7 @@ function menu( $icon, $name, $iconsub = '' ) { 'HTML' // for non-switch section , [ 'id' => 'ID' // REQUIRED - , 'input' => 'HTML' // alternative - if not switch + , 'input' => 'HTML/ID' // alternative - if not switch (ID - select) , 'setting' => TYPE // default = $( '#setting-'+ id ).click() before enable // false = no setting // 'custom' = custom setting @@ -195,7 +195,11 @@ function htmlSetting( $data ) { $disabled = isset( $data[ 'disabled' ] ) ? ''.$data[ 'disabled' ].'' : ''; $html .= ''; } else { - $html .= $input; + if ( $input[ 0 ] == '<' ) { + $html.= $input; + } else { // select + $html.= ''; + } } // setting $html .= $settingicon ? i( $settingicon.' setting', $id ) : ''; diff --git a/srv/http/settings/camilla.php b/srv/http/settings/camilla.php index 3b5d1dbf8..2ad04dda6 100644 --- a/srv/http/settings/camilla.php +++ b/srv/http/settings/camilla.php @@ -121,7 +121,7 @@ , [ 'id' => 'configuration' , 'status' => true - , 'input' => '' + , 'input' => 'configuration' , 'help' => $help[ 'volume' ] ] ]; diff --git a/srv/http/settings/player.php b/srv/http/settings/player.php index 11b779ef6..e6ad4adaa 100644 --- a/srv/http/settings/player.php +++ b/srv/http/settings/player.php @@ -1,15 +1,15 @@ [ 'label' => 'Device', 'setting' => 'none' ] - , 'autoupdate' => [ 'label' => 'Library Auto Update', 'sub' => 'auto_update', 'setting' => false ] + 'autoupdate' => [ 'label' => 'Library Auto Update', 'sub' => 'auto_update', 'setting' => false ] , 'bluealsa' => [ 'label' => 'Bluetooth', 'sub' => 'bluealsa', 'setting' => 'custom', 'status' => true ] , 'buffer' => [ 'label' => 'Buffer - Audio', 'sub' => 'audio_buffer' ] , 'crossfade' => [ 'label' => 'Cross-Fading', 'sub' => 'crossfade' ] , 'custom' => [ 'label' => "User's Configurations", 'sub' => 'custom' ] + , 'device' => [ 'label' => 'Device', 'setting' => 'none' ] , 'devicewithbt' => [ 'label' => 'Device + Bluetooth', 'setting' => false ] , 'dop' => [ 'label' => 'DSD over PCM', 'sub' => 'dop', 'setting' => 'none' ] , 'ffmpeg' => [ 'label' => 'FFmpeg', 'sub' => 'decoder', 'setting' => false ] - , 'hwmixer' => [ 'label' => 'Mixer Device', 'setting' => 'custom' ] + , 'mixer' => [ 'label' => 'Mixer Device', 'setting' => 'custom' ] , 'mixertype' => [ 'label' => 'Volume Control', 'setting' => 'custom' ] , 'normalization' => [ 'label' => 'Normalization', 'sub' => 'volume_normalization', 'setting' => false ] , 'novolume' => [ 'label' => 'No Volume', 'setting' => 'none' ] @@ -43,20 +43,20 @@ [ 'id' => 'bluealsa' , 'icon' => true - , 'input' => '' + , 'input' => 'btaplayname' , 'help' => <<< EOF {$Fi( 'volume btn' )} Sender volume control · Should be set at 0dB and use Bluetooth buttons to control volume EOF ] , [ - 'id' => 'audiooutput' - , 'input' => '' + 'id' => 'device' + , 'input' => 'device' , 'help' => 'HDMI audio: Available when connected before boot only' ] , [ - 'id' => 'hwmixer' - , 'input' => '' + 'id' => 'mixer' + , 'input' => 'mixer' , 'help' => i( 'volume btn' ).' Mixer device volume control' ] , [ diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 45b336649..b8fa4c347 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -238,7 +238,7 @@ ] , [ 'id' => 'timezone' - , 'input' => '' + , 'input' => 'timezone' , 'help' => <<< EOF {$Fi( 'gear btn' )} Servers for time sync and package mirror From f045b744dd27790dc8b42a46f7b03745691bbd0d Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Feb 2024 12:46:20 +0700 Subject: [PATCH 10/19] Update player.sh --- srv/http/bash/settings/player.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srv/http/bash/settings/player.sh b/srv/http/bash/settings/player.sh index 21475a7b9..0a9d04ca8 100644 --- a/srv/http/bash/settings/player.sh +++ b/srv/http/bash/settings/player.sh @@ -206,8 +206,8 @@ $bluealsa " devices+="\ -# aplay -l | grep ^card -$( aplay -l | grep ^card | grep -v 'Loopback.*device 1' ) +# cat /proc/asound/cards | grep ] +$( cat /proc/asound/cards | grep ] ) " if [[ ! -e $dirsystem/camilladsp ]]; then devices+=" From 527fe5bf246d7708c14bd8ea41ef058ae529b8dc Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Feb 2024 13:23:06 +0700 Subject: [PATCH 11/19] u --- srv/http/bash/settings/player-conf.sh | 2 +- srv/http/bash/settings/player-devices.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/srv/http/bash/settings/player-conf.sh b/srv/http/bash/settings/player-conf.sh index ba9435d80..39c195189 100644 --- a/srv/http/bash/settings/player-conf.sh +++ b/srv/http/bash/settings/player-conf.sh @@ -13,7 +13,7 @@ usbdac=$1 rm -f $dirmpdconf/{bluetooth,camilladsp,fifo}.conf -readarray -t proccards <<< $( sed -n '/]:/ {s/^.* - //; p}' /proc/asound/cards ) +readarray -t proccards <<< $( grep -v ] /proc/asound/cards | sed 's/^\s*//' ) if [[ $proccards ]]; then rm -f $dirshm/nosound . $dirsettings/player-devices.sh # >>> $asoundcard diff --git a/srv/http/bash/settings/player-devices.sh b/srv/http/bash/settings/player-devices.sh index e8e381b4d..a71898ea2 100644 --- a/srv/http/bash/settings/player-devices.sh +++ b/srv/http/bash/settings/player-devices.sh @@ -12,8 +12,8 @@ # - if nothing, set as software ### included by <<< player-conf.sh -! type -t args2va &> /dev/null && . /srv/http/bash/common.sh # if run directly -[[ ! $proccards ]] && readarray -t proccards <<< $( sed -n '/]:/ {s/^.* - //; p}' /proc/asound/cards ) # if run directly +! type -t args2va &> /dev/null && . /srv/http/bash/common.sh # if run directly +[[ ! $proccards ]] && readarray -t proccards <<< $( grep -v ] /proc/asound/cards | sed 's/^\s*//' ) # if run directly audioaplayname=$( getContent $dirsystem/audio-aplayname 'bcm2835 Headphones' ) audiooutput=$( getContent $dirsystem/audio-output 'On-board Headphones' ) From dff32e8d1f87b7e52346b46cea7e0b00c1000f32 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Feb 2024 13:27:27 +0700 Subject: [PATCH 12/19] Update player.sh --- srv/http/bash/settings/player.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srv/http/bash/settings/player.sh b/srv/http/bash/settings/player.sh index 0a9d04ca8..5825a2f55 100644 --- a/srv/http/bash/settings/player.sh +++ b/srv/http/bash/settings/player.sh @@ -206,8 +206,8 @@ $bluealsa " devices+="\ -# cat /proc/asound/cards | grep ] -$( cat /proc/asound/cards | grep ] ) +# cat /proc/asound/cards | grep -v ] | sed 's/^\s*//' +$( cat /proc/asound/cards | grep -v ] | sed 's/^\s*//' ) " if [[ ! -e $dirsystem/camilladsp ]]; then devices+=" From d2ca8f57f62c66827efd5c0c5567397d91793dbf Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Feb 2024 20:01:27 +0700 Subject: [PATCH 13/19] u --- srv/http/assets/css/settings.css | 3 +- srv/http/bash/audiocd.sh | 15 ++-- srv/http/bash/cmd-list.sh | 19 +++-- srv/http/bash/cmd.sh | 34 ++++----- srv/http/bash/common.sh | 18 ++--- srv/http/bash/dab-scan.sh | 6 +- srv/http/bash/settings/albumthumbnail.sh | 14 ++-- srv/http/bash/settings/features.sh | 13 ++-- srv/http/bash/settings/networks-data.sh | 12 ++-- srv/http/bash/settings/networks-scan.sh | 17 +++-- srv/http/bash/settings/player-conf.sh | 3 +- srv/http/bash/settings/player-devices.sh | 73 +++++++++++++------- srv/http/bash/settings/player.sh | 7 +- srv/http/bash/settings/system-data.sh | 4 +- srv/http/bash/settings/system-databackup.sh | 6 +- srv/http/bash/settings/system-datareset.sh | 16 +++-- srv/http/bash/settings/system-datarestore.sh | 16 +++-- srv/http/bash/settings/system-storage.sh | 11 ++- srv/http/bash/settings/system.sh | 6 +- srv/http/bash/status.sh | 10 +-- 20 files changed, 164 insertions(+), 139 deletions(-) diff --git a/srv/http/assets/css/settings.css b/srv/http/assets/css/settings.css index ff91270ee..c3c54c180 100644 --- a/srv/http/assets/css/settings.css +++ b/srv/http/assets/css/settings.css @@ -312,7 +312,8 @@ heading i.disabled { .entries li, .entries li span, .entries .li1, -.entries .li2 { +.entries .li2, +.select2-results__options li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; diff --git a/srv/http/bash/audiocd.sh b/srv/http/bash/audiocd.sh index 1dad3df7b..d16bada95 100644 --- a/srv/http/bash/audiocd.sh +++ b/srv/http/bash/audiocd.sh @@ -116,16 +116,17 @@ if [[ ! -e $diraudiocd/$discid ]]; then # cd-info discdata=$( sed -n '/^CD-TEXT for Disc/,/^\s*DISC_ID:/ {s/^\s*//; p}' <<< $cdinfo ) artist=$( grep ^PERFORMER <<< $discdata | cut -d' ' -f2- ) album=$( grep ^TITLE <<< $discdata | cut -d' ' -f2- ) - readarray -t lines <<< $( sed -n '/^CD-TEXT for Track/,$ {s/^\s*//; p}' <<< $cdinfo | tail +2 ) - lines+=( CD-TEXT- ) - for l in "${lines[@]}"; do - if [[ $l == TITLE:* ]]; then - t=$( sed 's/^TITLE: //' <<< $l ) - elif [[ $l == CD-TEXT* ]]; then + lines=$( sed -n '/^CD-TEXT for Track/,$ {s/^\s*//; p}' <<< $cdinfo | tail +2 ) + lines+=' +CD-TEXT-' + while read line; do + if [[ $line == TITLE:* ]]; then + t=$( sed 's/^TITLE: //' <<< $line ) + elif [[ $line == CD-TEXT* ]]; then titles+=( "$t" ) t= fi - done + done <<< $lines cdData fi fi diff --git a/srv/http/bash/cmd-list.sh b/srv/http/bash/cmd-list.sh index 4f084af68..bdb3b5891 100644 --- a/srv/http/bash/cmd-list.sh +++ b/srv/http/bash/cmd-list.sh @@ -79,21 +79,21 @@ if [[ ! $mpclistall ]]; then # very large database notify 'refresh-library blink' 'Library Database' 'Parse each album for large Library ...' 3000 echo 'max_output_buffer_size "8192"' > $dirmpdconf/outputbuffer.conf systemctl restart mpd - readarray -t albums <<< $( mpc list album 2> /dev/null ) + albums=$( mpc list album 2> /dev/null ) if [[ ! $albums ]]; then buffer=8192 for (( i=0; i < 10; i++ )); do buffer=$(( buffer + 8192 )) echo 'max_output_buffer_size "'$buffer'"' > $dirmpdconf/outputbuffer.conf systemctl restart mpd - readarray -t albums <<< $( mpc list album 2> /dev/null ) + albums=$( mpc list album 2> /dev/null ) [[ $albums ]] && break done fi if [[ $albums ]]; then - for a in "${albums[@]}"; do + while read a; do albumlist+=$( mpc -f '%album%^^[%albumartist%|%artist%]^^%date^^%file%' find album "$a" | awk -F'/[^/]*$' 'NF {print $1|"sort -u"}' )$'\n' - done + done <<< albums else notify 'refresh-library blink' 'Library Database' 'Library is too large.
Album list will not be available.' 3000 fi @@ -102,9 +102,9 @@ fi if [[ $albumlist ]]; then # album^^artist^^date^^dir filewav=$( grep \.wav$ <<< $mpclistall ) if [[ $filewav ]]; then # mpd not support *.wav albumartist - readarray -t dirwav <<< $( sed 's|.*\^||; s|/[^/]*$||' <<< $filewav | sort -u ) + dirwav=$( sed 's|.*\^||; s|/[^/]*$||' <<< $filewav | sort -u ) if [[ $dirwav ]]; then - for dir in "${dirwav[@]}"; do + while read dir; do dir=${dir//[/\\[/} # escape \[n-n] > not as range in grep file=$( grep -m1 "$dir" <<< $mpclistall ) albumartist=$( kid3-cli -c 'get albumartist' "/mnt/MPD/${file/*^}" ) @@ -115,12 +115,11 @@ if [[ $albumlist ]]; then # album^^artist^^date^^dir $( grep -v "$dir$" <<< $albumlist ) ${tags[0]}^^$albumartist^^${tags[2]}^^$dir" fi - done + done <<< $dirwav fi fi albumignore=$( getContent $dirmpd/albumignore ) - readarray -t lines <<< $albumlist - for line in "${lines[@]}"; do + while read line; do readarray -t tags <<< $( echo -e "${line//^^/\\n}" ) tagalbum=${tags[0]} tagartist=${tags[1]} @@ -131,7 +130,7 @@ ${tags[0]}^^$albumartist^^${tags[2]}^^$dir" album+="$tagalbum^^$tagartist^^$tagdir"$'\n' albumbyartist+="$tagartist^^$tagalbum^^$tagdir"$'\n' albumbyartistyear+="$tagartist^^$tagdate^^$tagalbum^^$tagdir"$'\n' - done + done <<< $albumlist for mode in album albumbyartist albumbyartist-year; do varname=${mode/-} sort -u <<< ${!varname} > $dirmpd/$mode diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index 46464be49..34b586059 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -492,13 +492,13 @@ mpcaddload ) ;; mpcaddls ) pos=$( plAddPosition ) - readarray -t cuefiles <<< $( mpc ls "$DIR" | grep '\.cue$' | sort -u ) + cuefiles=$( mpc ls "$DIR" | grep '\.cue$' | sort -u ) if [[ ! $cuefiles ]]; then mpc ls "$DIR" | mpc -q add &> /dev/null else - for cuefile in "${cuefiles[@]}"; do + while read cuefile; do mpc -q load "$cuefile" - done + done <<< $cuefiles fi plAddPlay $pos ;; @@ -594,27 +594,27 @@ mpcshuffle ) pushPlaylist ;; mpcsimilar ) - readarray -t lines <<< $( curl -sfG -m 5 \ - --data-urlencode "artist=$ARTIST" \ - --data-urlencode "track=$TITLE" \ - --data "method=track.getsimilar" \ - --data "api_key=$APIKEY" \ - --data "format=json" \ - --data "autocorrect=1" \ - http://ws.audioscrobbler.com/2.0 \ - | jq .similartracks.track \ - | sed -n '/"name": "/ {s/.*": "\|",$//g; p}' ) + lines=$( curl -sfG -m 5 \ + --data-urlencode "artist=$ARTIST" \ + --data-urlencode "track=$TITLE" \ + --data "method=track.getsimilar" \ + --data "api_key=$APIKEY" \ + --data "format=json" \ + --data "autocorrect=1" \ + http://ws.audioscrobbler.com/2.0 \ + | jq .similartracks.track \ + | sed -n '/"name": "/ {s/.*": "\|",$//g; p}' ) [[ ! $lines ]] && echo 'No similar tracks found in database.' && exit - for l in "${lines[@]}"; do # title \n artist + while read line; do if [[ $title ]]; then - file=$( mpc find artist "$l" title "$title" ) + file=$( mpc find artist "$line" title "$title" ) [[ $file ]] && list+="$file"$'\n' title= else - title=$l + title=$line fi - done + done <<< $lines [[ ! $list ]] && echo 'No similar tracks found in Library.' 5000 && exit plLprev=$( mpc status %length% ) diff --git a/srv/http/bash/common.sh b/srv/http/bash/common.sh index 1636b5d6a..a050755dc 100644 --- a/srv/http/bash/common.sh +++ b/srv/http/bash/common.sh @@ -117,18 +117,20 @@ conf2json() { [[ ! $lines ]] && echo false && return [[ $( head -1 <<< $lines ) != *=* ]] && lines=$( sed 's/^\s*//; s/ \+"/="/' <<< $lines ) # key "value" > key="value" - readarray -t lines <<< $lines - for l in "${lines[@]}"; do - k=${l/=*} - v=${l/*=} - [[ ! $v ]] && v=false + while read line; do + k=${line/=*} + v=${line/*=} + if [[ ${v/\"\"} ]]; then # omit v="" v=$( sed -E -e "s/^[\"']|[\"']$//g" \ -e 's/^True$|^yes$/true/ s/^False$|^no$/false/' <<< $v ) confNotString "$v" || v='"'$( stringEscape "$v" )'"' # quote and escape string - [[ ! $nocap ]] && k=${k^^} - json+=', "'$k'": '$v - done + else + v=false + fi + [[ ! $nocap ]] && k=${k^^} + json+=', "'$k'": '$v + done <<< $lines echo { ${json:1} } } confNotString() { diff --git a/srv/http/bash/dab-scan.sh b/srv/http/bash/dab-scan.sh index 3dad67803..617c5ab51 100644 --- a/srv/http/bash/dab-scan.sh +++ b/srv/http/bash/dab-scan.sh @@ -18,8 +18,8 @@ mkdir -p $dirdabradio/img mv $dirshm/img $dirdabradio &> /dev/null host=$( hostname -f ) -readarray -t services <<< $( sed -E -n '/^Ensemble|^audioservice/ {s/ *;/;/g; p}' $dirshm/dabscan ) -for service in "${services[@]}"; do +services=$( sed -E -n '/^Ensemble|^audioservice/ {s/ *;/;/g; p}' $dirshm/dabscan ) +while read service; do if [[ ${service:0:8} == Ensemble ]]; then ensemble=$( cut -d' ' -f2- <<< ${service/;*} | sed 's/\s*$//' ) mkdir "$dirdabradio/$ensemble" @@ -42,7 +42,7 @@ $name runOnDemandStartTimeout: 15s runOnDemandCloseAfter: 3s " -done +done <<< $services fileyml=/etc/mediamtx/mediamtx.yml sed -i '1,/^paths:/ !d' $fileyml diff --git a/srv/http/bash/settings/albumthumbnail.sh b/srv/http/bash/settings/albumthumbnail.sh index 5140e18a9..537c942f1 100644 --- a/srv/http/bash/settings/albumthumbnail.sh +++ b/srv/http/bash/settings/albumthumbnail.sh @@ -39,11 +39,9 @@ unsharp=0x.5 [[ ! $mpdpathlist ]] && echo "$padw No albums found in database." && exit -readarray -t lines <<< $mpdpathlist - -count=${#lines[@]} +count=${#mpdpathlist[@]} i=0 -for mpdpath in "${lines[@]}"; do +while read mpdpath; do (( i++ )) percent=$(( $i * 100 / $count )) if (( $percent > 0 )); then @@ -74,8 +72,8 @@ for mpdpath in "${lines[@]}"; do coverfile= done if [[ ! $coverfile ]]; then # embedded - readarray -t files <<< $( mpc ls "$mpdpath" 2> /dev/null ) - for file in "${files[@]}"; do + files=$( mpc ls "$mpdpath" 2> /dev/null ) + while read file; do file="/mnt/MPD/$file" if [[ -f "$file" ]]; then coverfile="$dir/cover.jpg" @@ -83,7 +81,7 @@ for mpdpath in "${lines[@]}"; do [[ ! -e $coverfile ]] && coverfile= break fi - done + done <<< $files fi if [[ $coverfile ]]; then ext=${coverfile: -3} @@ -102,7 +100,7 @@ for mpdpath in "${lines[@]}"; do else echo " $padgr No coverart found." fi -done +done <<< $mpdpathlist echo " Duration: $( date -d@$SECONDS -u +%H:%M:%S ) diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index 184872417..d64b6cf86 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -308,10 +308,9 @@ nfsserver ) files+=$'\n'$( ls -1 $dirplaylists/* ) files=$( awk NF <<< $files ) if [[ $files ]]; then - readarray -t files <<< $files - for file in "${files[@]}"; do + while read file; do sed -E -i '/^SD|^USB/ s|^|NAS/|' "$file" - done + done <<< $files fi else mv /mnt/MPD/NAS/{SD,USB} /mnt/MPD @@ -438,10 +437,10 @@ spotifykeyremove ) ;; spotifyoutput ) devices='"Default"' - readarray -t lines <<< $( aplay -L | grep ^.*:CARD ) - for l in ${lines[@]}; do - devices+=', "'$l'"' - done + lines=$( aplay -L | grep ^.*:CARD ) + while read line; do + devices+=', "'$line'"' + done <<< $lines current=$( sed -E -n '/^device/ {s/.*"(.*)"/\1/; p}' /etc/spotifyd.conf ) if [[ ${current:0:3} == hw: ]]; then current=Default diff --git a/srv/http/bash/settings/networks-data.sh b/srv/http/bash/settings/networks-data.sh index dd7ca338f..a682543e0 100644 --- a/srv/http/bash/settings/networks-data.sh +++ b/srv/http/bash/settings/networks-data.sh @@ -4,9 +4,9 @@ listBluetooth() { local dev devices info listbt mac - readarray -t devices <<< $( bluetoothctl devices Paired | sort -k3 -fh ) + devices=$( bluetoothctl devices Paired | sort -k3 -fh ) if [[ $devices ]]; then - for dev in "${devices[@]}"; do + while read dev; do mac=$( cut -d' ' -f2 <<< $dev ) info=$( bluetoothctl info $mac ) listbt+=',{ @@ -15,7 +15,7 @@ listBluetooth() { , "connected" : '$( grep -q -m1 'Connected: yes' <<< $info && echo true || echo false )' , "type" : "'$( awk '/UUID: Audio/ {print $3}' <<< $info | tr -d '\n' )'" }' - done + done <<< $devices echo [ ${listbt:1} ] fi } @@ -35,9 +35,9 @@ fi wlandev=$( < $dirshm/wlan ) listWlan() { local dbm notconnected profiles profile - readarray -t profiles <<< $( ls -1p /etc/netctl | grep -v /$ ) + profiles=$( ls -1p /etc/netctl | grep -v /$ ) if [[ $profiles ]]; then - for profile in "${profiles[@]}"; do + while read profile; do ssid=$( stringEscape $profile ) ! grep -q 'Interface="*'$wlandev "/etc/netctl/$profile" && continue if netctl is-active "$profile" &> /dev/null; then @@ -60,7 +60,7 @@ listWlan() { "ssid" : "'$ssid'" }' fi - done + done <<< $profiles fi [[ $notconnected ]] && listwl+="$notconnected" [[ $listwl ]] && listwl='[ '${listwl:1}' ]' || listwl=false diff --git a/srv/http/bash/settings/networks-scan.sh b/srv/http/bash/settings/networks-scan.sh index c965da53c..2a8ab06e9 100644 --- a/srv/http/bash/settings/networks-scan.sh +++ b/srv/http/bash/settings/networks-scan.sh @@ -33,11 +33,11 @@ if [[ $1 == wlan ]]; then | sort ) # omit saved profile - readarray -t profiles <<< $( ls -1p /etc/netctl | grep -v /$ ) + profiles=$( ls -1p /etc/netctl | grep -v /$ ) if [[ $profiles ]]; then - for profile in "${profiles[@]}"; do + while read profile; do scan=$( grep -v "ssid.*$profile" <<< $scan ) - done + done <<< $profiles fi echo "[ ${scan:1} ]" # ,{...} > [ {...} ] exit @@ -50,18 +50,17 @@ devices=$( bluetoothctl devices \ [[ ! $devices ]] && exit # omit paired devices -readarray -t paired <<< $( bluetoothctl devices Paired ) +paired=$( bluetoothctl devices Paired ) if [[ $paired ]]; then - for dev in "${paired[@]}"; do + while read dev; do devices=$( grep -v "$dev" <<< $devices ) - done + done <<< $paired fi -readarray -t devices <<< $devices -for dev in "${devices[@]}"; do +while read dev; do data+=',{ "mac" : "'$( cut -d' ' -f2 <<< $dev )'" , "name" : "'$( cut -d' ' -f3- <<< $dev )'" }' -done +done <<< $devices echo "[ ${data:1} ]" diff --git a/srv/http/bash/settings/player-conf.sh b/srv/http/bash/settings/player-conf.sh index 39c195189..149056aa2 100644 --- a/srv/http/bash/settings/player-conf.sh +++ b/srv/http/bash/settings/player-conf.sh @@ -13,8 +13,7 @@ usbdac=$1 rm -f $dirmpdconf/{bluetooth,camilladsp,fifo}.conf -readarray -t proccards <<< $( grep -v ] /proc/asound/cards | sed 's/^\s*//' ) -if [[ $proccards ]]; then +if aplay -l | grep -q ^card; then rm -f $dirshm/nosound . $dirsettings/player-devices.sh # >>> $asoundcard else diff --git a/srv/http/bash/settings/player-devices.sh b/srv/http/bash/settings/player-devices.sh index a71898ea2..8f657037d 100644 --- a/srv/http/bash/settings/player-devices.sh +++ b/srv/http/bash/settings/player-devices.sh @@ -12,34 +12,53 @@ # - if nothing, set as software ### included by <<< player-conf.sh -! type -t args2va &> /dev/null && . /srv/http/bash/common.sh # if run directly -[[ ! $proccards ]] && readarray -t proccards <<< $( grep -v ] /proc/asound/cards | sed 's/^\s*//' ) # if run directly - +! type -t args2va &> /dev/null && . /srv/http/bash/common.sh # if run directly +# snd_rpi_rpi_dac > i2s-dac (rpi-dac obsolete) +# snd_rpi_wsp > cirrus-wm5102 +# RPi-Cirrus > cirrus-wm5102 +# snd_rpi_xxx_yyy > xxx_yyy +# xxx_yyy > xxx-yyy +aplayl=$( aplay -l \ + | sed -n -E '/^card/ { + s/^card // + s/: /^/g + s/\[snd_rpi_rpi_dac]/[i2s-dac]/ + s/\[snd_rpi_wsp]|\[RPi-Cirrus]/[cirrus-wm5102]/ + s/\[snd_rpi_/[/ + s/ \[/^/g + s/, device /^/ + s/_/-/g + s/\]//g + p}' ) +# >>> 1card^...^3aplayname^4device^...^6name^ audioaplayname=$( getContent $dirsystem/audio-aplayname 'bcm2835 Headphones' ) audiooutput=$( getContent $dirsystem/audio-output 'On-board Headphones' ) -for aplayname in "${proccards[@]}"; do # <<< player-conf.sh - [[ ${aplayname:0:8} == snd_rpi_ ]] && aplayname=$( tr _ - <<< ${aplayname:8} ) # snd_rpi_xxx_yyy > xxx-yyy - [[ $aplayname == wsp || $aplayname == RPi-Cirrus ]] && aplayname=cirrus-wm5102 - [[ $aplayname == $audioaplayname ]] && name=$audiooutput || name=${aplayname/bcm2835/On-board} - LISTDEVICE+=', "'$name'": "'$aplayname'"' -done +while read line; do + aplayname=$( cut -d^ -f3 <<< $line ) + if [[ $aplayname == $audioaplayname ]]; then + name=$audiooutput + else + name=$( cut -d^ -f6 <<< $line ) + name=${name/bcm2835/On-board} + fi + name_device=', "'$name'": "'$aplayname'"' + ! grep -q "$name_device" <<< $LISTDEVICE && LISTDEVICE+=$name_device # suppress duplicate +done <<< $aplayl -aplayl=$( aplay -l | awk '/^card/ && !/Loopback/' ) if [[ $usbdac == add ]]; then # <<< player-conf.sh aplaycard=$( tail -1 <<< $aplayl ) elif [[ $aplayname == cirrus-wm5102 ]]; then - aplaycard=$( grep -m1 wm5102 <<< $aplayl ) + aplaycard=$( grep -m1 cirrus-wm5102 <<< $aplayl ) MIXER='HPOUT2 Digital' LISTMIXER=", 'HPOUT1 Digital', 'HPOUT2 Digital', 'SPDIF Out', 'Speaker Digital'" else aplaycard=$( grep -m1 "$audioaplayname" <<< $aplayl ) # avoid duplicate aplayname fi -readarray -t cnd <<< $( sed -E 's/card (.*):.*\[(.*)], device (.*):.*/\1\n\2\n\3/' <<< "$aplaycard" ) -CARD=${cnd[0]} -APLAYNAME=${cnd[1]} -DEVICE=${cnd[2]} -[[ $usbdac == add ]] && NAME=$APLAYNAME || NAME=$audiooutput +CARD=$( cut -d^ -f1 <<< $aplaycard ) +APLAYNAME=$( cut -d^ -f3 <<< $aplaycard ) +DEVICE=$( cut -d^ -f4 <<< $aplaycard ) +[[ $usbdac == add ]] && NAME=$APLAYNAME || NAME=$audiooutput if [[ ! $LISTMIXER ]]; then # ! cirrus-wm5102 amixer=$( amixer -c $CARD scontents ) if [[ $amixer ]]; then @@ -51,16 +70,16 @@ if [[ ! $LISTMIXER ]]; then # ! cirrus-wm5102 controls=$( grep -E 'volume.*pswitch|Master.*volume' <<< $amixer ) [[ ! $controls ]] && controls=$( grep volume <<< $amixer ) if [[ $controls ]]; then - readarray -t controls <<< $( cut -d"'" -f2 <<< $controls | sort -u ) - for control in "${controls[@]}"; do + controls=$( cut -d"'" -f2 <<< $controls | sort -u ) + while read control; do LISTMIXER+=', "'$control'"' [[ $control == Digital ]] && MIXER=Digital - done + done <<< $controls mixerfile="$dirsystem/mixer-$APLAYNAME" if [[ -e $mixerfile ]]; then # manual MIXER=$( < "$mixerfile" ) elif [[ ! $MIXER ]]; then # not Digital - MIXER=${controls[0]} + MIXER=$( head -1 <<< $controls ) fi fi fi @@ -72,15 +91,21 @@ else [[ $LISTMIXER ]] && MIXERTYPE=hardware || MIXERTYPE=none fi -[[ $MIXER ]] && echo "$MIXER" > $dirshm/amixercontrol || rm -f $dirshm/amixercontrol [[ $LISTDEVICE ]] && echo "{ ${LISTDEVICE:1} }" > $dirshm/listdevice || rm -f $dirshm/listdevice [[ $LISTMIXER ]] && echo "[ ${LISTMIXER:1} ]" > $dirshm/listmixer || rm -f $dirshm/listmixer -echo ' +if [[ $MIXER ]]; then + echo "$MIXER" > $dirshm/amixercontrol + output='mixer="'$MIXER'"' +else + rm -f $dirshm/amixercontrol + output='mixer=false' +fi +output+=' aplayname="'$APLAYNAME'" name="'$NAME'" card='$CARD' device='$DEVICE' -mixer="'$MIXER'" -mixertype='$MIXERTYPE > $dirshm/output +mixertype='$MIXERTYPE +echo "$output" > $dirshm/output echo $CARD > $dirsystem/asoundcard asoundcard=$CARD diff --git a/srv/http/bash/settings/player.sh b/srv/http/bash/settings/player.sh index 5825a2f55..6c830397e 100644 --- a/srv/http/bash/settings/player.sh +++ b/srv/http/bash/settings/player.sh @@ -180,17 +180,16 @@ statusalbumignore ) cat $dirmpd/albumignore ;; statusmpdignore ) - file=$dirmpd/mpdignorelist - readarray -t files < $file + files=$( < $dirmpd/mpdignorelist ) list="\ # find /mnt/MPD -name .mpdignore " - for file in "${files[@]}"; do + while read file; do list+="\ $file $( sed 's|^| |' "$file" ) " - done + done <<< $files echo "$list" ;; statusnonutf8 ) diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 882e400b0..4dc7144a8 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -115,7 +115,7 @@ packageActive bluetooth nfs-server rotaryencoder smb if [[ -e $dirsystem/audio-aplayname && -e $dirsystem/audio-output ]]; then audioaplayname=$( < $dirsystem/audio-aplayname ) audiooutput=$( < $dirsystem/audio-output ) - i2smodulesw=$( grep -q "$audiooutput.*$audioaplayname" /srv/http/assets/data/system-i2s.json && echo true ) + i2ssw=$( grep -q "$audiooutput.*$audioaplayname" /srv/http/assets/data/system-i2s.json && echo true ) fi # reboot if [[ -e $dirshm/reboot ]]; then @@ -177,7 +177,7 @@ data=' , "hddsleep" : '${hddapm/128/false}' , "hostname" : "'$( hostname )'" , "i2seeprom" : '$( grep -q -m1 force_eeprom_read=0 /boot/config.txt && echo true )' -, "i2smodulesw" : '$i2smodulesw' +, "i2ssw" : '$i2ssw' , "ipsub" : "'$( ipAddress sub )'" , "lcdchar" : '$( exists $dirsystem/lcdchar )' , "lcdcharaddr" : '$lcdcharaddr' diff --git a/srv/http/bash/settings/system-databackup.sh b/srv/http/bash/settings/system-databackup.sh index c9176a331..7e350ae4a 100644 --- a/srv/http/bash/settings/system-databackup.sh +++ b/srv/http/bash/settings/system-databackup.sh @@ -38,15 +38,15 @@ crossfade=$( mpc crossfade | cut -d' ' -f2 ) [[ $crossfade ]] && echo $crossfade > $dirsystem/crossfade hostname > $dirsystem/hostname timedatectl | awk '/zone:/ {print $3}' > $dirsystem/timezone -readarray -t profiles <<< $( ls -p /etc/netctl | grep -v / ) +profiles=$( ls -p /etc/netctl | grep -v / ) if [[ $profiles ]]; then cp -r /etc/netctl $dirconfig/etc - for profile in "${profiles[@]}"; do + while read profile; do if [[ $( netctl is-enabled "$profile" ) == enabled ]]; then echo $profile > $dirsystem/netctlprofile break fi - done + done <<< $profiles fi mkdir -p $dirconfig/var/lib cp -r /var/lib/bluetooth $dirconfig/var/lib &> /dev/null diff --git a/srv/http/bash/settings/system-datareset.sh b/srv/http/bash/settings/system-datareset.sh index e2a89595e..5e05748e0 100644 --- a/srv/http/bash/settings/system-datareset.sh +++ b/srv/http/bash/settings/system-datareset.sh @@ -57,10 +57,12 @@ echo "$config" > /boot/config.txt # lcd sed -i 's/fb1/fb0/' /etc/X11/xorg.conf.d/99-fbturbo.conf &> /dev/null # nas -readarray -t dirs <<< $( find $dirnas -mindepth 1 -maxdepth 1 -type d ) -for dir in "${dirs[@]}"; do - umount -l "$dir" &> /dev/null - rmdir "$dir" &> /dev/null +dirs=$( find $dirnas -mindepth 1 -maxdepth 1 -type d ) +if [[ $dirs ]]; then + while read dir; do + umount -l "$dir" &> /dev/null + rmdir "$dir" &> /dev/null + done <<< $dirs done sed -i '3,$ d' /etc/fstab @@ -71,12 +73,12 @@ rm -rf $dirdata $dirshareddata \ /mnt/MPD/.mpdignore $dirnas/.mpdignore \ /etc/modules-load.d/{loopback,raspberrypi}.conf /etc/modprobe.d/cirrus.conf /etc/X11/xorg.conf.d/99-raspi-rotate.conf if [[ ! $keepnetwork ]]; then - readarray -t profiles <<< $( ls -p /etc/netctl | grep -v / ) + profiles=$( ls -p /etc/netctl | grep -v / ) if [[ $profiles ]]; then - for profile in "${profiles[@]}"; do + while read profile; do [[ $( netctl is-enabled "$profile" ) == enabled ]] && netctl disable "$profile" rm "/etc/netctl/$profile" - done + done <<< $profiles fi fi diff --git a/srv/http/bash/settings/system-datarestore.sh b/srv/http/bash/settings/system-datarestore.sh index b3c9154a4..2755bfd82 100644 --- a/srv/http/bash/settings/system-datarestore.sh +++ b/srv/http/bash/settings/system-datarestore.sh @@ -41,15 +41,17 @@ CMD NAME" timedatectl set-timezone $( < $dirsystem/timezone ) [[ -e $dirsystem/crossfade ]] && mpc crossfade $( < $dirsystem/crossfade ) rm -rf $backupfile $dirconfig $dirsystem/{crossfade,enable,disable,hostname,netctlprofile,timezone} -readarray -t dirs <<< $( find $dirnas -mindepth 1 -maxdepth 1 -type d ) -for dir in "${dirs[@]}"; do - umount -l "$dir" &> /dev/null - rmdir "$dir" &> /dev/null +dirs=$( find $dirnas -mindepth 1 -maxdepth 1 -type d ) +if [[ $dirs ]]; then + while read dir; do + umount -l "$dir" &> /dev/null + rmdir "$dir" &> /dev/null + done <<< $dirs done -readarray -t mountpoints <<< $( grep $dirnas /etc/fstab | awk '{print $2}' | sed 's/\\040/ /g' ) +mountpoints=$( grep $dirnas /etc/fstab | awk '{print $2}' | sed 's/\\040/ /g' ) if [[ $mountpoints ]]; then - for mountpoint in $mountpoints; do + while read mountpoint; do mkdir -p "$mountpoint" - done + done <<< $mountpoints fi $dirbash/power.sh reboot diff --git a/srv/http/bash/settings/system-storage.sh b/srv/http/bash/settings/system-storage.sh index bc712a0ce..c0493687d 100644 --- a/srv/http/bash/settings/system-storage.sh +++ b/srv/http/bash/settings/system-storage.sh @@ -15,8 +15,7 @@ if [[ ! -e $filesharedip ]]; then fi usb=$( mount | grep ^/dev/sd | cut -d' ' -f1 ) if [[ $usb ]]; then - readarray -t usb <<< $usb - for source in "${usb[@]}"; do + while read source; do mountpoint=$( df -l --output=target,source | sed -n "\|$source| {s| *$source||; p}" ) if [[ $mountpoint ]]; then used_size=( $( df -lh --output=used,size,source | grep "$source" ) ) @@ -35,13 +34,13 @@ if [[ ! -e $filesharedip ]]; then [[ ! $hddapm ]] && hddapm=$( hdparm -B $source \ | grep -m1 APM_level \ | tr -d -c 0-9 ) - done + done <<< $usb fi fi nas=$( grep -E '/mnt/MPD/NAS|/srv/http/data' /etc/fstab | tr -s ' ' ) if [[ $nas ]]; then - readarray -t nas <<< $( cut -d' ' -f1-2 <<< $nas | sort ) - for line in "${nas[@]}"; do + nas=$( cut -d' ' -f1-2 <<< $nas | sort ) + while read line; do source=${line/ *} source=${source//\\040/ } mountpoint=${line/* } @@ -62,6 +61,6 @@ if [[ $nas ]]; then , "source" : "'$source'" }' fi - done + done <<< $nas fi echo "[ ${list:1} ]" diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index d19b9e00b..e956a8e50 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -236,9 +236,9 @@ mirrorlist ) else list=$( < $file ) fi - readarray -t lines <<< $( sed -E -n '/^### Mirror/,$ {/^\s*$|^### Mirror/ d; s|.*//(.*)\.mirror.*|\1|; p}' <<< $list ) + lines=$( sed -E -n '/^### Mirror/,$ {/^\s*$|^### Mirror/ d; s|.*//(.*)\.mirror.*|\1|; p}' <<< $list ) codelist='"Auto":""' - for line in "${lines[@]}"; do + while read line; do if [[ ${line:0:4} == '### ' ]];then city= country=${line:4} @@ -250,7 +250,7 @@ mirrorlist ) ccprev=$cc codelist+=',"'$cc'":"'$line'"' fi - done + done <<< $lines echo '{ '$codelist' }' ;; mountforget ) diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index d30142e3d..7289b2b2a 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -167,10 +167,10 @@ pos=$( mpc status %songpos% ) filter='Album AlbumArtist Artist Composer Conductor audio bitrate duration file state Time Title' [[ ! $snapclient ]] && filter+=' playlistlength consume random repeat single' filter=^${filter// /:|^}: # ^Album|^AlbumArtist|^Artist... -readarray -t lines <<< $( { echo clearerror; echo status; echo playlistinfo $song; sleep 0.05; } \ - | telnet 127.0.0.1 6600 2> /dev/null \ - | grep -E $filter ) -for line in "${lines[@]}"; do +lines=$( { echo clearerror; echo status; echo playlistinfo $song; sleep 0.05; } \ + | telnet 127.0.0.1 6600 2> /dev/null \ + | grep -E $filter ) +while read line; do key=${line/:*} val=${line#*: } case $key in @@ -199,7 +199,7 @@ for line in "${lines[@]}"; do , "'$key'" : '$val ;; esac -done +done <<< $lines [[ $playlistlength ]] && pllength=$playlistlength || pllength=0 ######## From 498533a69fd2a9fa08c5e0e1b0343df655358292 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Feb 2024 20:05:15 +0700 Subject: [PATCH 14/19] Update player-devices.sh --- srv/http/bash/settings/player-devices.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/srv/http/bash/settings/player-devices.sh b/srv/http/bash/settings/player-devices.sh index 8f657037d..e901b8d4e 100644 --- a/srv/http/bash/settings/player-devices.sh +++ b/srv/http/bash/settings/player-devices.sh @@ -35,11 +35,15 @@ audioaplayname=$( getContent $dirsystem/audio-aplayname 'bcm2835 Headphones' ) audiooutput=$( getContent $dirsystem/audio-output 'On-board Headphones' ) while read line; do aplayname=$( cut -d^ -f3 <<< $line ) - if [[ $aplayname == $audioaplayname ]]; then - name=$audiooutput - else - name=$( cut -d^ -f6 <<< $line ) + name=$( cut -d^ -f6 <<< $line ) + if [[ $name ]]; then name=${name/bcm2835/On-board} + else + if [[ $aplayname == $audioaplayname ]]; then + name=$audiooutput + else + name=$aplayname + fi fi name_device=', "'$name'": "'$aplayname'"' ! grep -q "$name_device" <<< $LISTDEVICE && LISTDEVICE+=$name_device # suppress duplicate From b8a6444786c76593cd11c1bc4e7bc337488e8bdd Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Feb 2024 21:00:53 +0700 Subject: [PATCH 15/19] u --- srv/http/bash/settings/player-devices.sh | 33 ++++++++++++++---------- srv/http/bash/settings/player.sh | 7 +++-- srv/http/settings/player.php | 5 +++- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/srv/http/bash/settings/player-devices.sh b/srv/http/bash/settings/player-devices.sh index e901b8d4e..e4efbe945 100644 --- a/srv/http/bash/settings/player-devices.sh +++ b/srv/http/bash/settings/player-devices.sh @@ -31,38 +31,38 @@ aplayl=$( aplay -l \ s/\]//g p}' ) # >>> 1card^...^3aplayname^4device^...^6name^ -audioaplayname=$( getContent $dirsystem/audio-aplayname 'bcm2835 Headphones' ) -audiooutput=$( getContent $dirsystem/audio-output 'On-board Headphones' ) +if [[ -e $dirsystem/output-aplayname ]]; then # device set from player page + device=$( < $dirsystem/output-aplayname ) +else # device set from system page + device=$( getContent $dirsystem/audio-aplayname 'bcm2835 Headphones' ) + outputname=$( getContent $dirsystem/audio-output 'On-board Headphones' ) +fi while read line; do aplayname=$( cut -d^ -f3 <<< $line ) name=$( cut -d^ -f6 <<< $line ) if [[ $name ]]; then name=${name/bcm2835/On-board} else - if [[ $aplayname == $audioaplayname ]]; then - name=$audiooutput - else - name=$aplayname - fi + [[ $aplayname == $device ]] && name=$outputname || name=$aplayname fi - name_device=', "'$name'": "'$aplayname'"' - ! grep -q "$name_device" <<< $LISTDEVICE && LISTDEVICE+=$name_device # suppress duplicate + name_device=' +, "'$name'": "'$aplayname'"' + LISTDEVICE+=$name_device # suppress duplicate done <<< $aplayl if [[ $usbdac == add ]]; then # <<< player-conf.sh aplaycard=$( tail -1 <<< $aplayl ) -elif [[ $aplayname == cirrus-wm5102 ]]; then +elif [[ $device == cirrus-wm5102 ]]; then aplaycard=$( grep -m1 cirrus-wm5102 <<< $aplayl ) MIXER='HPOUT2 Digital' LISTMIXER=", 'HPOUT1 Digital', 'HPOUT2 Digital', 'SPDIF Out', 'Speaker Digital'" else - aplaycard=$( grep -m1 "$audioaplayname" <<< $aplayl ) # avoid duplicate aplayname + aplaycard=$( grep -m1 "$device" <<< $aplayl ) # avoid duplicate aplayname fi - CARD=$( cut -d^ -f1 <<< $aplaycard ) APLAYNAME=$( cut -d^ -f3 <<< $aplaycard ) DEVICE=$( cut -d^ -f4 <<< $aplaycard ) -[[ $usbdac == add ]] && NAME=$APLAYNAME || NAME=$audiooutput +NAME=$( cut -d^ -f6 <<< $aplaycard ) if [[ ! $LISTMIXER ]]; then # ! cirrus-wm5102 amixer=$( amixer -c $CARD scontents ) if [[ $amixer ]]; then @@ -95,7 +95,12 @@ else [[ $LISTMIXER ]] && MIXERTYPE=hardware || MIXERTYPE=none fi -[[ $LISTDEVICE ]] && echo "{ ${LISTDEVICE:1} }" > $dirshm/listdevice || rm -f $dirshm/listdevice +if [[ $LISTDEVICE ]]; then + LISTDEVICE=$( awk NF <<< $LISTDEVICE | sort -u ) + echo "{ ${LISTDEVICE:1} }" > $dirshm/listdevice +else + rm -f $dirshm/listdevice +fi [[ $LISTMIXER ]] && echo "[ ${LISTMIXER:1} ]" > $dirshm/listmixer || rm -f $dirshm/listmixer if [[ $MIXER ]]; then echo "$MIXER" > $dirshm/amixercontrol diff --git a/srv/http/bash/settings/player.sh b/srv/http/bash/settings/player.sh index 6c830397e..3eca8ae76 100644 --- a/srv/http/bash/settings/player.sh +++ b/srv/http/bash/settings/player.sh @@ -66,8 +66,11 @@ custom ) fi ;; device ) - echo $APLAYNAME > $dirsystem/audio-aplayname - echo $OUTPUT > $dirsystem/audio-output + if [[ $APLAYNAME == $( getContent $dirsystem/audio-aplayname ) ]]; then + rm -f $dirsystem/output-aplayname + else + echo $APLAYNAME > $dirsystem/output-aplayname + fi $dirsettings/player-conf.sh ;; devicewithbt ) diff --git a/srv/http/settings/player.php b/srv/http/settings/player.php index e6ad4adaa..fab22bf8d 100644 --- a/srv/http/settings/player.php +++ b/srv/http/settings/player.php @@ -52,7 +52,10 @@ , [ 'id' => 'device' , 'input' => 'device' - , 'help' => 'HDMI audio: Available when connected before boot only' + , 'help' => <<< EOF + · Device name: Retrieved from I²S module + · HDMI audio: Available when connected before boot only +EOF ] , [ 'id' => 'mixer' From 370c829898ba011c11a301357fcb5928ce5d05bd Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Feb 2024 21:09:39 +0700 Subject: [PATCH 16/19] u --- srv/http/bash/settings/player-devices.sh | 7 +++++++ srv/http/settings/player.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/srv/http/bash/settings/player-devices.sh b/srv/http/bash/settings/player-devices.sh index e4efbe945..5fce83e19 100644 --- a/srv/http/bash/settings/player-devices.sh +++ b/srv/http/bash/settings/player-devices.sh @@ -63,6 +63,13 @@ CARD=$( cut -d^ -f1 <<< $aplaycard ) APLAYNAME=$( cut -d^ -f3 <<< $aplaycard ) DEVICE=$( cut -d^ -f4 <<< $aplaycard ) NAME=$( cut -d^ -f6 <<< $aplaycard ) +if [[ ! $NAME ]]; then + if [[ $APLAYNAME == $( getContent $dirsystem/audio-aplayname ) ]]; then + NAME=$( getContent $dirsystem/audio-output ) + else + NAME=$APLAYNAME + fi +fi if [[ ! $LISTMIXER ]]; then # ! cirrus-wm5102 amixer=$( amixer -c $CARD scontents ) if [[ $amixer ]]; then diff --git a/srv/http/settings/player.php b/srv/http/settings/player.php index fab22bf8d..23817f6e5 100644 --- a/srv/http/settings/player.php +++ b/srv/http/settings/player.php @@ -53,7 +53,7 @@ 'id' => 'device' , 'input' => 'device' , 'help' => <<< EOF - · Device name: Retrieved from I²S module + · Device name: Retrieved from I²S module (if available) · HDMI audio: Available when connected before boot only EOF ] From 30bb9ea409322f22aaf48ae8efe43691308e571e Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Feb 2024 21:21:19 +0700 Subject: [PATCH 17/19] Update system.sh --- srv/http/bash/settings/system.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index e956a8e50..4b63454b8 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -97,6 +97,7 @@ soundProfile() { case $CMD in audio ) + enableFlagSet config=$( grep -v dtparam=audio=on /boot/config.txt ) [[ $ON ]] && config+=" dtparam=audio=on" @@ -189,6 +190,8 @@ i2smodule ) prevaplayname=$( getContent $dirsystem/audio-aplayname ) config=$( grep -Ev "dtparam=i2s=on|dtoverlay=$prevaplayname|gpio=25=op,dh|dtparam=audio=on" /boot/config.txt ) if [[ $APLAYNAME != none ]]; then + [[ -e $dirsystem/audio ]] && config+=" +dtparam=audio=on" config+=" dtparam=i2s=on dtoverlay=$APLAYNAME" From 2b30c3939ac57e561a1d8de936859557d7af7b38 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Feb 2024 21:32:56 +0700 Subject: [PATCH 18/19] Update system.js --- srv/http/assets/js/system.js | 41 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 404ed9da3..1e6f31c65 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -120,7 +120,7 @@ $( 'body' ).on( 'click', function( e ) { if ( e.target.id !== 'codehddinfo' ) $( '#codehddinfo' ).addClass( 'hide' ); $( 'li' ).removeClass( 'active' ); if ( ! $( e.target ).hasClass( 'select2-search__field' ) - && ! $( e.target ).parents( '#divi2smodule' ).length + && ! $( e.target ).parents( '#divi2sselect' ).length && $( '#i2smodule' ).val() === 'none' ) { i2sSelectHide(); @@ -133,16 +133,17 @@ $( '.close' ).off( 'click' ).on( 'click', function() { // off close in settings. return } - var line = 'Reboot required for:

'; - list.split( '\n' ).forEach( id => line += ico( id ) + $( '#div'+ id +' .label' ).text() +'\n' ); + var message = 'Reboot required for:'; + list.split( '\n' ).forEach( id => message += '
'+ ico( id ) + $( '#div'+ id +' .label' ).text() ); // i2smodule info( { - icon : page - , title : 'System Setting' - , message : line +'

' - , cancel : () => location.href = '/' - , okcolor : orange - , oklabel : ico( 'reboot' ) +'Reboot' - , ok : () => infoPowerCommand( 'reboot' ) + icon : page + , title : 'System Setting' + , message : message + , messagealign : 'left' + , cancel : () => location.href = '/' + , okcolor : orange + , oklabel : ico( 'reboot' ) +'Reboot' + , ok : () => infoPowerCommand( 'reboot' ) } ); } ); } ); @@ -309,10 +310,10 @@ $( '#setting-wlan' ).on( 'click', function() { }, 'json' ); } } ); -$( '#divi2smodulesw' ).on( 'click', function() { +$( '#divi2ssw' ).on( 'click', function() { setTimeout( i2sOptionSet, 0 ); } ); -$( '#divi2s .col-r' ).on( 'click', function( e ) { +$( '#divi2smodule .col-r' ).on( 'click', function( e ) { if ( $( e.target ).parents( '.select2' ).length ) i2sOptionSet(); } ); $( '#i2smodule' ).on( 'input', function() { @@ -324,7 +325,7 @@ $( '#i2smodule' ).on( 'input', function() { notify( icon, title, 'Enable ...' ); } else { setTimeout( () => { notify( icon, title, 'Disable ...' ) }, 300 ); // fix - hide banner too soon - S.i2smodulesw = false; + S.i2ssw = false; i2sSelectHide(); } bash( [ 'i2smodule', aplayname, output, 'CMD APLAYNAME OUTPUT' ] ); @@ -682,7 +683,7 @@ $( '#i2smodule, #timezone' ).on( 'select2:opening', function () { // temp css fo function i2sOptionSet() { if ( $( '#i2smodule option' ).length > 2 ) { - if ( $( '#divi2smodule' ).hasClass( 'hide' ) ) { + if ( $( '#divi2sselect' ).hasClass( 'hide' ) ) { i2sSelectShow(); $( '#i2smodule' ).select2( 'open' ); } @@ -703,13 +704,13 @@ function i2sOptionSetSelect() { } ).prop( 'selected', true ); } function i2sSelectHide() { - $( '#i2smodulesw' ).prop( 'checked', S.i2smodulesw ); - $( '#divi2smodulesw' ).removeClass( 'hide' ); - $( '#divi2smodule' ).addClass( 'hide' ); + $( '#i2ssw' ).prop( 'checked', S.i2ssw ); + $( '#divi2ssw' ).removeClass( 'hide' ); + $( '#divi2sselect' ).addClass( 'hide' ); } function i2sSelectShow() { - $( '#divi2smodulesw' ).addClass( 'hide' ); - $( '#divi2smodule, #setting-i2smodule' ).removeClass( 'hide' ); + $( '#divi2ssw' ).addClass( 'hide' ); + $( '#divi2sselect, #setting-i2smodule' ).removeClass( 'hide' ); } function htmlOption( values ) { var options = ''; @@ -1127,7 +1128,7 @@ function renderPage() { } else { $( '#divaudio' ).addClass( 'hide' ); } - if ( S.i2smodulesw ) { + if ( S.i2ssw ) { if ( $( '#i2smodule option' ).length ) { i2sOptionSetSelect(); } else { From a0444967d5620b5621c617324288ee737291867c Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Feb 2024 21:35:41 +0700 Subject: [PATCH 19/19] u --- srv/http/assets/css/common.css | 1 + srv/http/settings/system.php | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/srv/http/assets/css/common.css b/srv/http/assets/css/common.css index e65adb631..0d8c69bf8 100644 --- a/srv/http/assets/css/common.css +++ b/srv/http/assets/css/common.css @@ -107,6 +107,7 @@ i { .i-hide::before { content: '\F575' } .i-hostname::before { content: '\F590' } .i-httpd::before { content: '\F55D' } +.i-i2s::before { content: '\F571' } .i-i2smodule::before { content: '\F571' } .i-info::before { content: '\F561' } .i-input::before { content: '\F529' } diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index b8fa4c347..056a59e95 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -148,14 +148,16 @@ $body = [ [ 'html' => <<< EOF -
-
Audio - I²S
+
+
-
- -
+
+ +
-
+