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..0d8c69bf8 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;
@@ -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' }
@@ -232,7 +233,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/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/assets/js/player.js b/srv/http/assets/js/player.js
index 8e70f3b90..e986c72d8 100644
--- a/srv/http/assets/js/player.js
+++ b/srv/http/assets/js/player.js
@@ -1,22 +1,21 @@
-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.';
$( 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';
@@ -24,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
@@ -76,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() )
@@ -317,30 +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' );
- delete typelist[ 'Mixer device' ];
+ $( '#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 );
@@ -350,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/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 {
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 e7e1b2b12..a050755dc 100644
--- a/srv/http/bash/common.sh
+++ b/srv/http/bash/common.sh
@@ -117,19 +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$|^False$/\L&/
- s/^yes$/true/
- s/^no$/false/' <<< $v )
- confNotString "$v" || v='"'$( stringEscape $v )'"' # quote and escape string
- [[ ! $nocap ]] && k=${k^^}
- json+=', "'$k'": '$v
- done
+ -e 's/^True$|^yes$/true/
+ s/^False$|^no$/false/' <<< $v )
+ confNotString "$v" || v='"'$( stringEscape "$v" )'"' # quote and escape string
+ 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-asound.sh b/srv/http/bash/settings/player-asound.sh
index c0591a8ff..ecd603d23 100644
--- a/srv/http/bash/settings/player-asound.sh
+++ b/srv/http/bash/settings/player-asound.sh
@@ -1,12 +1,10 @@
#!/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=$( < $dirsystem/asoundcard )
-[[ ! $asoundcard ]] && asoundcard=0
-if [[ $asoundcard != -1 ]]; then
+if [[ $asoundcard != -1 ]]; then # <<< player-devices.sh
########
asound="\
defaults.pcm.card $asoundcard
@@ -93,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 ba1a6729f..149056aa2 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
@@ -12,20 +12,19 @@
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
+if aplay -l | grep -q ^card; then
+ 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 +54,6 @@ $audiooutputbt
" > $dirmpdconf/bluetooth.conf
########
fi
-asoundcard=$( < $dirsystem/asoundcard )
if [[ $asoundcard == -1 ]]; then # no audio devices
rm -f $dirmpdconf/{output,soxr}.conf
if [[ $usbdac == remove ]]; then
@@ -64,7 +62,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
@@ -74,6 +72,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
@@ -99,7 +98,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 +155,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 +163,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 +185,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 e898cde9c..5fce83e19 100644
--- a/srv/http/bash/settings/player-devices.sh
+++ b/srv/http/bash/settings/player-devices.sh
@@ -11,39 +11,67 @@
# - set as hardware if mixer device available
# - if nothing, set as software
-### included by 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' )
-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'"'
-done
-########
-echo "{ ${listdevice:1} }" > $dirshm/listdevice
+### included by <<< player-conf.sh
+! 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^
+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
+ [[ $aplayname == $device ]] && name=$outputname || name=$aplayname
+ fi
+ name_device='
+, "'$name'": "'$aplayname'"'
+ LISTDEVICE+=$name_device # suppress duplicate
+done <<< $aplayl
-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 )
- hwmixer='HPOUT2 Digital'
- listmixer='[ "HPOUT1 Digital", "HPOUT2 Digital", "SPDIF Out", "Speaker Digital" ]'
+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
-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
-
-if [[ $aplayname != cirrus-wm5102 ]]; then
- amixer=$( amixer -c $card scontents )
+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
amixer=$( grep -A1 ^Simple <<< $amixer \
| sed 's/^\s*Cap.*: /^/' \
@@ -53,36 +81,47 @@ if [[ $aplayname != cirrus-wm5102 ]]; then
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
- listmixer+=', "'$control'"'
- [[ $control == Digital ]] && hwmixer=Digital
- done
- listmixer="[ ${listmixer:1} ]"
- hwmixerfile="$dirsystem/hwmixer-$aplayname"
- if [[ -e $hwmixerfile ]]; then # manual
- hwmixer=$( < "$hwmixerfile" )
- elif [[ ! $hwmixer ]]; then # not Digital
- hwmixer=${controls[0]}
+ controls=$( cut -d"'" -f2 <<< $controls | sort -u )
+ while read control; do
+ LISTMIXER+=', "'$control'"'
+ [[ $control == Digital ]] && MIXER=Digital
+ done <<< $controls
+ mixerfile="$dirsystem/mixer-$APLAYNAME"
+ if [[ -e $mixerfile ]]; then # manual
+ MIXER=$( < "$mixerfile" )
+ elif [[ ! $MIXER ]]; then # not Digital
+ MIXER=$( head -1 <<< $controls )
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
-echo '
-aplayname="'$aplayname'"
-name="'$name'"
-card='$card'
-device='$device'
-hwmixer='$hwmixer'
-mixertype='$mixertype > $dirshm/output
+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
+ output='mixer="'$MIXER'"'
+else
+ rm -f $dirshm/amixercontrol
+ output='mixer=false'
+fi
+output+='
+aplayname="'$APLAYNAME'"
+name="'$NAME'"
+card='$CARD'
+device='$DEVICE'
+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 8b9da2a6a..3eca8ae76 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,14 @@ custom )
$dirsettings/player-conf.sh
fi
;;
+device )
+ if [[ $APLAYNAME == $( getContent $dirsystem/audio-aplayname ) ]]; then
+ rm -f $dirsystem/output-aplayname
+ else
+ echo $APLAYNAME > $dirsystem/output-aplayname
+ fi
+ $dirsettings/player-conf.sh
+ ;;
devicewithbt )
enableFlagSet
[[ -e $dirmpdconf/bluetooth.conf ]] && bluetooth=1
@@ -101,9 +104,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 +119,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 +129,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
@@ -180,17 +183,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 )
@@ -206,8 +208,8 @@ $bluealsa
"
devices+="\
-# aplay -l | grep ^card
-$( aplay -l | grep ^card | grep -v 'Loopback.*device 1' )
+# cat /proc/asound/cards | grep -v ] | sed 's/^\s*//'
+$( cat /proc/asound/cards | grep -v ] | sed 's/^\s*//' )
"
if [[ ! -e $dirsystem/camilladsp ]]; then
devices+="
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..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"
@@ -236,9 +239,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 +253,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
########
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..23817f6e5 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,23 @@
[
'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' => ''
- , 'help' => 'HDMI audio: Available when connected before boot only'
+ 'id' => 'device'
+ , 'input' => 'device'
+ , 'help' => <<< EOF
+ · Device name: Retrieved from I²S module (if available)
+ · HDMI audio: Available when connected before boot only
+EOF
]
, [
- '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..056a59e95 100644
--- a/srv/http/settings/system.php
+++ b/srv/http/settings/system.php
@@ -148,14 +148,16 @@
$body = [
[
'html' => <<< EOF
-
-
Audio - I²S
+
+
-
-
-
+
-
+
@@ -238,7 +240,7 @@
]
, [
'id' => 'timezone'
- , 'input' => '
'
+ , 'input' => 'timezone'
, 'help' => <<< EOF
{$Fi( 'gear btn' )}
Servers for time sync and package mirror