From 049c81a0b5e8f0ce7beb92181f4987a3d93fae28 Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 2 Sep 2022 20:05:25 +0700 Subject: [PATCH 01/19] Update addons.sh --- srv/http/bash/addons.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/srv/http/bash/addons.sh b/srv/http/bash/addons.sh index e289b18b9..22ad5a1c4 100644 --- a/srv/http/bash/addons.sh +++ b/srv/http/bash/addons.sh @@ -74,12 +74,9 @@ title() { getinstallzip() { echo $bar Get files ... installfile=$branch.tar.gz - curl -skLO $( jq -r .$alias.installurl $addonsjson \ + curl -sfkLO $( jq -r .$alias.installurl $addonsjson \ | sed "s|raw/main/install.sh|archive/$installfile|" ) - if [[ ! -e $installfile ]]; then - echo -e "$warn Get files failed." - exit - fi + [[ $? != 0 ]] && echo -e "$warn Get files failed." && exit echo echo $bar Install new files ... From a4d02be276af743ae44f1f21769cf491bab0327b Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 2 Sep 2022 20:55:32 +0700 Subject: [PATCH 02/19] u --- srv/http/bash/addons.sh | 3 ++- srv/http/bash/cmd.sh | 3 ++- srv/http/bash/settings/system.sh | 7 +++---- srv/http/bash/status-coverartonline.sh | 12 +++++++----- srv/http/settings/addons-progress.php | 6 +++--- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/srv/http/bash/addons.sh b/srv/http/bash/addons.sh index 22ad5a1c4..0fa38ec86 100644 --- a/srv/http/bash/addons.sh +++ b/srv/http/bash/addons.sh @@ -74,8 +74,9 @@ title() { getinstallzip() { echo $bar Get files ... installfile=$branch.tar.gz - curl -sfkLO $( jq -r .$alias.installurl $addonsjson \ + fileurl=$( jq -r .$alias.installurl $addonsjson \ | sed "s|raw/main/install.sh|archive/$installfile|" ) + curl -sfLO $fileurl [[ $? != 0 ]] && echo -e "$warn Get files failed." && exit echo diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index 4739a5043..9c504babc 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -10,7 +10,8 @@ addonsListGet() { : >/dev/tcp/8.8.8.8/53 || ( echo -2 && exit ) # online check [[ ! $1 ]] && branch=main || branch=$1 - curl -skL https://github.com/rern/rAudio-addons/raw/$branch/addons-list.json -o $diraddons/addons-list.json || ( echo -1 && exit ) + curl -sfL https://github.com/rern/rAudio-addons/raw/$branch/addons-list.json -o $diraddons/addons-list.json + [[ $? != 0 ]] && echo -1 && exit } equalizerGet() { # sudo - mixer equal is user dependent val=$( sudo -u mpd amixer -MD equal contents | awk -F ',' '/: value/ {print $NF}' | xargs ) diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 1f9289520..37ba25b6f 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -451,10 +451,9 @@ mirrorlist ) | head -1 \ | sed 's|\.*mirror.*||; s|.*//||' ) [[ ! $current ]] && current=0 - if ! grep -q '^###' $file; then - pushstreamNotifyBlink 'Mirror List' 'Get ...' globe - curl -skL https://github.com/archlinuxarm/PKGBUILDs/raw/master/core/pacman-mirrorlist/mirrorlist -o $file - fi + pushstreamNotifyBlink 'Mirror List' 'Get ...' globe + curl -sfLO https://github.com/archlinuxarm/PKGBUILDs/raw/master/core/pacman-mirrorlist/mirrorlist + [[ $? == 0 ]] && mv -f mirrorlist $file || rm mirrorlist readarray -t lines <<< $( awk NF $file \ | sed -n '/### A/,$ p' \ | sed 's/ (not Austria\!)//; s/.mirror.*//; s|.*//||' ) diff --git a/srv/http/bash/status-coverartonline.sh b/srv/http/bash/status-coverartonline.sh index 81fe1552c..747d87075 100644 --- a/srv/http/bash/status-coverartonline.sh +++ b/srv/http/bash/status-coverartonline.sh @@ -22,14 +22,14 @@ else method='method=album.getInfo' fi apikey=$( grep apikeylastfm /srv/http/assets/js/main.js | cut -d"'" -f2 ) -data=$( curl -sGk -m 5 \ +data=$( curl -sfG -m 5 \ --data-urlencode "artist=$artist" \ --data-urlencode "$param" \ --data "$method" \ --data "api_key=$apikey" \ --data "format=json" \ http://ws.audioscrobbler.com/2.0 ) -[[ $data =~ error ]] && exit +[[ $? != 0 || $data =~ error ]] && exit if [[ $type == webradio ]]; then album=$( jq -r .track.album <<< "$data" ) @@ -46,7 +46,10 @@ if [[ $image && $image != null ]]; then else ### 2 - coverartarchive.org ##################################### mbid=$( jq -r .mbid <<< "$album" ) - [[ $mbid && $mbid != null ]] && url=$( curl -skL -m 10 https://coverartarchive.org/release/$mbid | jq -r .images[0].image ) + if [[ $mbid && $mbid != null ]]; then + imgdata=$( curl -sfL -m 10 https://coverartarchive.org/release/$mbid ) + [[ $? == 0 ]] && url=$( echo "$imgdata" | jq -r .images[0].image ) + fi fi fi [[ ! $url || $url == null ]] && exit @@ -58,8 +61,7 @@ else [[ $type ]] && prefix=$type || prefix=online coverfile=$dirshm/$prefix/$name.$ext fi -curl -sL $url -o $coverfile -[[ ! -e $coverfile ]] && exit +curl -sfL $url -o $coverfile || exit data=' "url" : "'${coverfile:9}'" diff --git a/srv/http/settings/addons-progress.php b/srv/http/settings/addons-progress.php index 6623d4a4d..56c926571 100644 --- a/srv/http/settings/addons-progress.php +++ b/srv/http/settings/addons-progress.php @@ -90,7 +90,7 @@ Date: Fri, 2 Sep 2022 20:59:05 +0700 Subject: [PATCH 03/19] Update system.sh --- srv/http/bash/settings/system.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 37ba25b6f..b1e0fb1ec 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -451,9 +451,11 @@ mirrorlist ) | head -1 \ | sed 's|\.*mirror.*||; s|.*//||' ) [[ ! $current ]] && current=0 - pushstreamNotifyBlink 'Mirror List' 'Get ...' globe - curl -sfLO https://github.com/archlinuxarm/PKGBUILDs/raw/master/core/pacman-mirrorlist/mirrorlist - [[ $? == 0 ]] && mv -f mirrorlist $file || rm mirrorlist + if : >/dev/tcp/8.8.8.8/53; then + pushstreamNotifyBlink 'Mirror List' 'Get ...' globe + curl -sfLO https://github.com/archlinuxarm/PKGBUILDs/raw/master/core/pacman-mirrorlist/mirrorlist + [[ $? == 0 ]] && mv -f mirrorlist $file || rm mirrorlist + fi readarray -t lines <<< $( awk NF $file \ | sed -n '/### A/,$ p' \ | sed 's/ (not Austria\!)//; s/.mirror.*//; s|.*//||' ) From 9d609a7c4dad8c77da412ac729a44c8f0550afd8 Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 3 Sep 2022 18:23:15 +0700 Subject: [PATCH 04/19] u --- srv/http/bash/settings/networks-data.sh | 22 ++++++++++++---------- srv/http/bash/settings/networks-scan.sh | 22 ++++++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/srv/http/bash/settings/networks-data.sh b/srv/http/bash/settings/networks-data.sh index 4a928a96f..adcbb445f 100644 --- a/srv/http/bash/settings/networks-data.sh +++ b/srv/http/bash/settings/networks-data.sh @@ -4,21 +4,23 @@ # bluetooth if systemctl -q is-active bluetooth; then - controller=$( bluetoothctl show | head -1 | cut -d' ' -f2 ) - readarray -t macs <<< $( ls -1 /var/lib/bluetooth/$controller | egrep -v 'cache|settings' ) - if [[ $macs ]]; then - for mac in "${macs[@]}"; do + readarray -t devices <<< $( bluetoothctl devices Paired \ + | cut -d' ' -f2,3- \ + | sort -k2 -fh ) + if [[ $devices ]]; then + for dev in "${devices[@]}"; do + mac=${dev/ *} + name=${dev/$mac } readarray -t info <<< $( bluetoothctl info $mac \ - | egrep 'Name: |Connected: |UUID: Audio' \ - | sed -E 's/^\s*Name: // - s/^\s*Connected: yes/true/ + | egrep 'Connected: |UUID: Audio' \ + | sed -E 's/^\s*Connected: yes/true/ s/^\s*Connected: no/false/ s/\s*UUID: Audio (.*) .*/\1/' ) listbt+=',{ "mac" : "'$mac'" -, "name" : "'${info[0]}'" -, "connected" : '${info[1]}' -, "type" : "'${info[2]}'" +, "name" : "'$name'" +, "connected" : '${info[0]}' +, "type" : "'${info[1]}'" }' done listbt="[ ${listbt:1} ]" diff --git a/srv/http/bash/settings/networks-scan.sh b/srv/http/bash/settings/networks-scan.sh index 47425dbff..487518759 100644 --- a/srv/http/bash/settings/networks-scan.sh +++ b/srv/http/bash/settings/networks-scan.sh @@ -48,21 +48,23 @@ fi bluetoothctl --timeout=10 scan on &> /dev/null devices=$( bluetoothctl devices \ | grep -v ' ..-..-..-..-..-..$' \ - | sed -E 's/Device (..:..:..:..:..:..) (.*)/\2^\1/' \ - | sort -f ) + | cut -d' ' -f2,3- \ + | sort -k2 -fh ) [[ ! $devices ]] && exit -controller=$( bluetoothctl show | head -1 | cut -d' ' -f2 ) -readarray -t macs <<< $( ls -1 /var/lib/bluetooth/$controller | egrep -v 'cache|settings' ) -if [[ $macs ]]; then - for mac in "${macs[@]}"; do - devices=$( grep -v $mac <<< "$devices" ) - done +paired=$( bluetoothctl devices Paired \ + | cut -d' ' -f2,3- \ + | sort -k2 -fh ) +if [[ $paired ]]; then + devices=$( echo "$devices +$paired" \ + | sort \ + | uniq -u ) fi readarray -t devices <<< "$devices" for dev in "${devices[@]}"; do - name=${dev/^*} - mac=${dev/*^} + mac=${dev/ *} + name=${dev/$mac } data+=',{ "name" : "'$name'" , "mac" : "'$mac'" From e82d10ce63f1b6890d2a33a22736728bd549fb0e Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 3 Sep 2022 20:45:02 +0700 Subject: [PATCH 05/19] u --- srv/http/bash/settings/networks-data.sh | 12 +++++------- srv/http/bash/settings/networks-scan.sh | 25 +++++++++---------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/srv/http/bash/settings/networks-data.sh b/srv/http/bash/settings/networks-data.sh index adcbb445f..9f5403030 100644 --- a/srv/http/bash/settings/networks-data.sh +++ b/srv/http/bash/settings/networks-data.sh @@ -4,21 +4,19 @@ # bluetooth if systemctl -q is-active bluetooth; then - readarray -t devices <<< $( bluetoothctl devices Paired \ - | cut -d' ' -f2,3- \ - | sort -k2 -fh ) + readarray -t devices <<< $( bluetoothctl devices Paired | sort -k3 -fh ) if [[ $devices ]]; then for dev in "${devices[@]}"; do - mac=${dev/ *} - name=${dev/$mac } + name=$( echo $dev | cut -d' ' -f3- ) + mac=$( echo $dev | cut -d' ' -f2 ) readarray -t info <<< $( bluetoothctl info $mac \ | egrep 'Connected: |UUID: Audio' \ | sed -E 's/^\s*Connected: yes/true/ s/^\s*Connected: no/false/ s/\s*UUID: Audio (.*) .*/\1/' ) listbt+=',{ - "mac" : "'$mac'" -, "name" : "'$name'" + "name" : "'$name'" +, "mac" : "'$mac'" , "connected" : '${info[0]}' , "type" : "'${info[1]}'" }' diff --git a/srv/http/bash/settings/networks-scan.sh b/srv/http/bash/settings/networks-scan.sh index 487518759..2922c85d8 100644 --- a/srv/http/bash/settings/networks-scan.sh +++ b/srv/http/bash/settings/networks-scan.sh @@ -39,35 +39,28 @@ if [[ $1 == wlan ]]; then # connected ssid connectedssid=$( iwgetid $wlandev -r ) scan=$( sed '/"ssid":"'$connectedssid'"/ a\,"connected":true' <<< "$scan" ) - - # },{... > [ {...} ] - echo "[ ${scan:2} } ]" | jq + + echo "[ ${scan:2} } ]" # },{... > [ {...} ] exit fi bluetoothctl --timeout=10 scan on &> /dev/null -devices=$( bluetoothctl devices \ - | grep -v ' ..-..-..-..-..-..$' \ - | cut -d' ' -f2,3- \ - | sort -k2 -fh ) +devices=$( bluetoothctl devices | grep -v ' ..-..-..-..-..-..$' ) [[ ! $devices ]] && exit -paired=$( bluetoothctl devices Paired \ - | cut -d' ' -f2,3- \ - | sort -k2 -fh ) +paired=$( bluetoothctl devices Paired ) if [[ $paired ]]; then devices=$( echo "$devices $paired" \ - | sort \ + | sort -k3 -fh \ | uniq -u ) fi readarray -t devices <<< "$devices" for dev in "${devices[@]}"; do - mac=${dev/ *} - name=${dev/$mac } data+=',{ -"name" : "'$name'" -, "mac" : "'$mac'" + "name" : "'$( echo $dev | cut -d' ' -f3- )'" +, "mac" : "'$( echo $dev | cut -d' ' -f2 )'" }' done -data2json "$data" + +echo "[ ${data:1} ]" # ,{...} > [ {...} ] From ada5acbcd3f131c8aa807bba9a00fd2442196d99 Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 3 Sep 2022 22:24:38 +0700 Subject: [PATCH 06/19] u --- srv/http/assets/js/networks.js | 21 ------------ srv/http/bash/settings/networks-data.sh | 14 +++----- srv/http/bash/settings/networks-scan.sh | 44 ++++++++++++------------- 3 files changed, 25 insertions(+), 54 deletions(-) diff --git a/srv/http/assets/js/networks.js b/srv/http/assets/js/networks.js index e54cd5812..c2eb69ed4 100644 --- a/srv/http/assets/js/networks.js +++ b/srv/http/assets/js/networks.js @@ -521,28 +521,9 @@ function scanBluetooth() { function scanWlan() { bash( '/srv/http/bash/settings/networks-scan.sh wlan', function( data ) { if ( data ) { - var signals = ''; - data.forEach( function( list, i, obj ) { - if ( !list.ssid ) { // remove blank ssid - obj.splice( i, 1 ); - return - } - - if ( list.signal != 0 ) signals += list.signal; - } ); - data.sort( function( a, b ) { - if ( signals ) { - var ab = signals.includes( 'dBm' ) ? [ a.signal, b.signal ] : [ b.signal, a.signal ]; - } else { - var ab = [ a.ssid, b.ssid ]; - } - return ab[ 0 ].localeCompare( ab[ 1 ], 'en', { numeric: true } ) - } ); G.listwlscan = data; var htmlwl = ''; data.forEach( function( list, i ) { - if ( 'profile' in list ) return - if ( list.signal.slice( -3 ) === 'dBm' ) { var dbm = parseInt( list.signal.slice( 0, -4 ) ); var signal = dbm > -60 ? '' : ( dbm < -67 ? 1 : 2 ); @@ -551,11 +532,9 @@ function scanWlan() { var signal = ''; } htmlwl += '
  • '; - if ( list.connected ) htmlwl += ' '; htmlwl += dbm && dbm < -67 ? ''+ list.ssid +'' : list.ssid; if ( list.encrypt === 'on') htmlwl += ' '; if ( list.signal != 0 ) htmlwl += ''+ list.signal +''; - if ( list.profile && !list.connected ) htmlwl += ' '; htmlwl += '
  • '; } ); } else { diff --git a/srv/http/bash/settings/networks-data.sh b/srv/http/bash/settings/networks-data.sh index 9f5403030..86d3ff43b 100644 --- a/srv/http/bash/settings/networks-data.sh +++ b/srv/http/bash/settings/networks-data.sh @@ -7,18 +7,12 @@ if systemctl -q is-active bluetooth; then readarray -t devices <<< $( bluetoothctl devices Paired | sort -k3 -fh ) if [[ $devices ]]; then for dev in "${devices[@]}"; do - name=$( echo $dev | cut -d' ' -f3- ) mac=$( echo $dev | cut -d' ' -f2 ) - readarray -t info <<< $( bluetoothctl info $mac \ - | egrep 'Connected: |UUID: Audio' \ - | sed -E 's/^\s*Connected: yes/true/ - s/^\s*Connected: no/false/ - s/\s*UUID: Audio (.*) .*/\1/' ) listbt+=',{ - "name" : "'$name'" -, "mac" : "'$mac'" -, "connected" : '${info[0]}' -, "type" : "'${info[1]}'" + "mac" : "'$mac'" +, "name" : "'$( echo $dev | cut -d' ' -f3- )'" +, "connected" : '$( bluetoothctl devices Connected | grep -q $mac && echo true || echo false )' +, "type" : "'$( bluetoothctl info $mac | grep -q 'UUID: Audio' && echo true || echo false )'" }' done listbt="[ ${listbt:1} ]" diff --git a/srv/http/bash/settings/networks-scan.sh b/srv/http/bash/settings/networks-scan.sh index 2922c85d8..454976ee3 100644 --- a/srv/http/bash/settings/networks-scan.sh +++ b/srv/http/bash/settings/networks-scan.sh @@ -6,20 +6,15 @@ if [[ $1 == wlan ]]; then wlandev=$( cat $dirshm/wlan ) ip link set $wlandev up - # pre-scan hidden ssid to force responding to scan - readarray -t hiddenprofiles <<< $( grep -rl --exclude-dir=examples ^Hidden=yes /etc/netctl ) - if [[ $hiddenprofiles ]]; then - for file in "${hiddenprofiles[@]}"; do - iwlist $wlandev scan essid "$( basename "$file" )" &> /dev/null - done - fi - # ESSID:"NAME" # Encryption key:on # Quality=37/70 Signal level=-73 dBm --- Quality=0/100 Signal level=25/100 # IE: IEEE 802.11i/WPA2 Version 1 # IE: WPA Version 1 - scan=$( iwlist $wlandev scan \ + scan=$( iwlist $wlandev scan ) + [[ ! $scan ]] && exit + + scan=$( echo "$scan" \ | sed -E 's/^\s*|\s*$//g' \ | egrep '^Cell|^ESSID|^Encryption|^IE.*WPA|^Quality' \ | sed -E 's/^Cell.*/},{/ @@ -28,19 +23,21 @@ if [[ $1 == wlan ]]; then s/^Encryption key:(.*)/,"encrypt":"\1"/ s/^IE.*WPA.*/,"wpa":true/ s/^Quality.*level.(.*)/,"signal":"\1"/' \ - | sed '/},{/ {n;s/^,/ /}' ) - # save profile - readarray -t ssids <<< $( grep '"ssid":' <<< "$scan" \ - | sed -E 's/^.*:"(.*)"/\1/' \ - | awk NF ) - for ssid in "${ssids[@]}"; do - [[ -e "/etc/netctl/$ssid" ]] && scan=$( sed '/"ssid":"'$ssid'"/ a\,"profile":true' <<< "$scan" ) + | tr -d '\n' \ + | sed 's/{,/{/g; s/,{/\n&/g' \ + | sed -e '1 d' \ + -e '$ s/$/}/' \ + -e '/"ssid":""/ d' \ + -e 's/wpa.*wpa/wpa/' \ + | sort ) + + # omit saved profile + readarray -t profiles <<< $( ls -1p /etc/netctl | grep -v /$ ) + for profile in "${profiles[@]}"; do + scan=$( grep -v "ssid.*$profile" <<< "$scan" ) done - # connected ssid - connectedssid=$( iwgetid $wlandev -r ) - scan=$( sed '/"ssid":"'$connectedssid'"/ a\,"connected":true' <<< "$scan" ) - echo "[ ${scan:2} } ]" # },{... > [ {...} ] + echo "[ ${scan:1} ]" # ,{...} > [ {...} ] exit fi @@ -48,6 +45,7 @@ bluetoothctl --timeout=10 scan on &> /dev/null devices=$( bluetoothctl devices | grep -v ' ..-..-..-..-..-..$' ) [[ ! $devices ]] && exit +# omit paired devices paired=$( bluetoothctl devices Paired ) if [[ $paired ]]; then devices=$( echo "$devices @@ -58,9 +56,9 @@ fi readarray -t devices <<< "$devices" for dev in "${devices[@]}"; do data+=',{ - "name" : "'$( echo $dev | cut -d' ' -f3- )'" -, "mac" : "'$( echo $dev | cut -d' ' -f2 )'" + "mac" : "'$( echo $dev | cut -d' ' -f2 )'" +, "name" : "'$( echo $dev | cut -d' ' -f3- )'" }' done -echo "[ ${data:1} ]" # ,{...} > [ {...} ] +echo "[ ${data:1} ]" From f71aac5262924e9b5cf93be01a25308c50161e41 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 4 Sep 2022 09:05:39 +0700 Subject: [PATCH 07/19] u --- srv/http/bash/settings/networks-data.sh | 5 +++-- srv/http/bash/settings/networks-scan.sh | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/srv/http/bash/settings/networks-data.sh b/srv/http/bash/settings/networks-data.sh index 86d3ff43b..5cbf85ec7 100644 --- a/srv/http/bash/settings/networks-data.sh +++ b/srv/http/bash/settings/networks-data.sh @@ -8,11 +8,12 @@ if systemctl -q is-active bluetooth; then if [[ $devices ]]; then for dev in "${devices[@]}"; do mac=$( echo $dev | cut -d' ' -f2 ) + info=$( bluetoothctl info $mac ) listbt+=',{ "mac" : "'$mac'" , "name" : "'$( echo $dev | cut -d' ' -f3- )'" -, "connected" : '$( bluetoothctl devices Connected | grep -q $mac && echo true || echo false )' -, "type" : "'$( bluetoothctl info $mac | grep -q 'UUID: Audio' && echo true || echo false )'" +, "connected" : '$( echo "$info" | grep -q 'Connected: yes' && echo true || echo false )' +, "type" : "'$( echo "$info" | awk '/UUID: Audio/ {print $3}' )'" }' done listbt="[ ${listbt:1} ]" diff --git a/srv/http/bash/settings/networks-scan.sh b/srv/http/bash/settings/networks-scan.sh index 454976ee3..674aef262 100644 --- a/srv/http/bash/settings/networks-scan.sh +++ b/srv/http/bash/settings/networks-scan.sh @@ -18,17 +18,17 @@ if [[ $1 == wlan ]]; then | sed -E 's/^\s*|\s*$//g' \ | egrep '^Cell|^ESSID|^Encryption|^IE.*WPA|^Quality' \ | sed -E 's/^Cell.*/},{/ - s/^ESSID:/,"ssid":/ - s/\\x00//g + s/^Quality.*level.(.*)/,"signal":"\1"/ s/^Encryption key:(.*)/,"encrypt":"\1"/ + s/^ESSID:/,"ssid":/ s/^IE.*WPA.*/,"wpa":true/ - s/^Quality.*level.(.*)/,"signal":"\1"/' \ + s/\\x00//g' \ | tr -d '\n' \ | sed 's/{,/{/g; s/,{/\n&/g' \ | sed -e '1 d' \ - -e '$ s/$/}/' \ -e '/"ssid":""/ d' \ -e 's/wpa.*wpa/wpa/' \ + -e '$ s/$/}/' \ | sort ) # omit saved profile From 5e537013b8666d1a2c0742c67e2e65e41b62f9ea Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 4 Sep 2022 09:16:49 +0700 Subject: [PATCH 08/19] Update networks-scan.sh --- srv/http/bash/settings/networks-scan.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/srv/http/bash/settings/networks-scan.sh b/srv/http/bash/settings/networks-scan.sh index 674aef262..0c18fb5ee 100644 --- a/srv/http/bash/settings/networks-scan.sh +++ b/srv/http/bash/settings/networks-scan.sh @@ -17,7 +17,7 @@ if [[ $1 == wlan ]]; then scan=$( echo "$scan" \ | sed -E 's/^\s*|\s*$//g' \ | egrep '^Cell|^ESSID|^Encryption|^IE.*WPA|^Quality' \ - | sed -E 's/^Cell.*/},{/ + | sed -E 's/^Cell.*/,{/ s/^Quality.*level.(.*)/,"signal":"\1"/ s/^Encryption key:(.*)/,"encrypt":"\1"/ s/^ESSID:/,"ssid":/ @@ -25,10 +25,8 @@ if [[ $1 == wlan ]]; then s/\\x00//g' \ | tr -d '\n' \ | sed 's/{,/{/g; s/,{/\n&/g' \ - | sed -e '1 d' \ - -e '/"ssid":""/ d' \ - -e 's/wpa.*wpa/wpa/' \ - -e '$ s/$/}/' \ + | sed -E -e '/^$|"ssid":""/ d' \ + -e 's/wpa.*wpa/wpa/; s/$/}/' \ | sort ) # omit saved profile From 0feb0237b96e8ee9707aca367e77dee2a49280cd Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 4 Sep 2022 09:29:54 +0700 Subject: [PATCH 09/19] Update context.js --- srv/http/assets/js/context.js | 1 + 1 file changed, 1 insertion(+) diff --git a/srv/http/assets/js/context.js b/srv/http/assets/js/context.js index 3113919f1..5b63f46a5 100644 --- a/srv/http/assets/js/context.js +++ b/srv/http/assets/js/context.js @@ -454,6 +454,7 @@ function webRadioEdit() { if ( url.includes( 'stream.radioparadise.com' ) || url.includes( 'icecast.radiofrance.fr' ) ) { $( '#infoContent' ).find( 'tr:eq( 2 ), tr:eq( 3 )' ).remove(); } + if $( $( '#lib-path .lipath' ).text() ) $( '#addwebradiodir' ).remove(); } , oklabel : 'Save' , ok : function() { From 6689a8a064a5c076ab8f8aa33a061d2469e5a3c6 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 4 Sep 2022 09:40:07 +0700 Subject: [PATCH 10/19] Update context.js --- srv/http/assets/js/context.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/srv/http/assets/js/context.js b/srv/http/assets/js/context.js index 5b63f46a5..9f21f6251 100644 --- a/srv/http/assets/js/context.js +++ b/srv/http/assets/js/context.js @@ -450,11 +450,10 @@ function webRadioEdit() { , checkblank : [ 0, 1 ] , boxwidth : 'max' , beforeshow : function() { - $( '#addwebradiodir' ).empty(); + $( '#addwebradiodir' ).remove(); if ( url.includes( 'stream.radioparadise.com' ) || url.includes( 'icecast.radiofrance.fr' ) ) { $( '#infoContent' ).find( 'tr:eq( 2 ), tr:eq( 3 )' ).remove(); } - if $( $( '#lib-path .lipath' ).text() ) $( '#addwebradiodir' ).remove(); } , oklabel : 'Save' , ok : function() { @@ -492,19 +491,23 @@ function webRadioNew( name, url, charset ) { , values : name ? [ name, url, charset ] : [ '', '', 'UTF-8' ] , checkblank : [ 0, 1 ] , beforeshow : function() { - $( '#addwebradiodir' ).click( function() { - info( { - icon : 'webradio' - , title : 'Add New Folder' - , textlabel : 'Name' - , focus : 0 - , checkblank : 1 - , ok : function() { - var dir = $( '#lib-path .lipath' ).text(); - bash( [ 'wrdirnew', dir, infoVal() ] ); - } + if ( $( '#lib-path .lipath' ).text() ) { + $( '#addwebradiodir' ).remove(); + } else { + $( '#addwebradiodir' ).click( function() { + info( { + icon : 'webradio' + , title : 'Add New Folder' + , textlabel : 'Name' + , focus : 0 + , checkblank : 1 + , ok : function() { + var dir = $( '#lib-path .lipath' ).text(); + bash( [ 'wrdirnew', dir, infoVal() ] ); + } + } ); } ); - } ); + } } , ok : function() { var values = infoVal(); From f98fff529b752e58651a023b3a14330f139c169c Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 4 Sep 2022 09:48:40 +0700 Subject: [PATCH 11/19] Update networks.js --- srv/http/assets/js/networks.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/srv/http/assets/js/networks.js b/srv/http/assets/js/networks.js index c2eb69ed4..5c6ee7710 100644 --- a/srv/http/assets/js/networks.js +++ b/srv/http/assets/js/networks.js @@ -9,7 +9,7 @@ $( '.container' ).click( function( e ) { } ); $( '.back' ).click( function() { clearTimeout( G.timeoutScan ); - $( '#divinterface' ).removeClass( 'hide' ); + $( '#help, #divinterface' ).removeClass( 'hide' ); $( '#divbluetooth, #divwifi, #divwebui' ).addClass( 'hide' ); $( '#listwlscan, #listbtscan' ).empty(); refreshData(); @@ -24,7 +24,7 @@ $( '#btscan' ).click( function() { return } - $( '#divinterface, #divwebui, #divaccesspoint' ).addClass( 'hide' ); + $( '#help, #divinterface, #divwebui, #divaccesspoint' ).addClass( 'hide' ); $( '#divbluetooth' ).removeClass( 'hide' ); scanBluetooth(); } ); @@ -39,7 +39,13 @@ $( '#wladd' ).click( function() { G.hostapd ? infoAccesspoint() : infoWiFi(); } ); $( '#wlscan' ).click( function() { - G.hostapd ? infoAccesspoint() : wlanStatus(); + if ( G.hostapd ) { + infoAccesspoint(); + } else { + $( '#help, #divinterface, #divwebui, #divaccesspoint' ).addClass( 'hide' ); + $( '#divwifi' ).removeClass( 'hide' ); + scanWlan(); + } } ); $( '#lanadd' ).click( function() { info( { @@ -544,8 +550,3 @@ function scanWlan() { G.timeoutScan = setTimeout( scanWlan, 12000 ); }, 'json' ); } -function wlanStatus() { - $( '#divinterface, #divwebui, #divaccesspoint' ).addClass( 'hide' ); - $( '#divwifi' ).removeClass( 'hide' ); - scanWlan(); -} From b6e44e608bdbea3213be1c88a1e6a4e559c51a11 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 4 Sep 2022 12:09:12 +0700 Subject: [PATCH 12/19] Add files via upload --- srv/http/bash/status.sh | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index 714d1be61..2762099c6 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -190,27 +190,24 @@ for line in "${lines[@]}"; do bitdepth=${data[1]} ;; bitrate ) - bitrate=$(( val * 1000 ));; - # true/false + bitrate=$(( val * 1000 )) + ;; + duration | playlistlength | song | state | Time ) + printf -v $key '%s' $val;; # value of $key as "var name" - value of $val as "var value" + Album | AlbumArtist | Artist | Name | Title ) # string to escape " for json + printf -v $key '%s' "${val//\"/\\\"}" + ;; + file ) + file0=$val # no escape " for coverart and ffprobe + [[ $file0 == *".cue/track"* ]] && file0=$( dirname "$file0" ) + file=${val//\"/\\\"} # escape " for json + ;; random | repeat | single ) [[ $val == 1 ]] && tf=true || tf=false ######## status+=' , "'$key'" : '$tf ;; - # number - duration | playlistlength | song | Time ) - printf -v $key '%s' $val;; # value of $key as "var name" - value of $val as "var value" - # string - escaped name - Album | AlbumArtist | Artist | Name | Title ) - printf -v $key '%s' "${val//\"/\\\"}";; # escape " for json - file ) - file0=$val # no escape " for coverart and ffprobe - [[ $file0 == *".cue/track"* ]] && file0=$( dirname "$file0" ) - file=${val//\"/\\\"};; # escape " for json - # string - * ) # state | updating_db - [[ $key ]] && printf -v $key '%s' "$val";; esac done @@ -423,7 +420,7 @@ samplingLine() { -v quiet \ -show_entries format=bit_rate \ -of default=noprint_wrappers=1:nokey=1 \ - "/mnt/MPD/$file" ) + "/mnt/MPD/$file0" ) fi fi if (( $bitrate < 1000000 )); then From 3d160e173731121edac51e145541929ec11daebd Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 4 Sep 2022 13:32:33 +0700 Subject: [PATCH 13/19] Update status.sh --- srv/http/bash/status.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index 2762099c6..3aa1bc1b9 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -198,8 +198,8 @@ for line in "${lines[@]}"; do printf -v $key '%s' "${val//\"/\\\"}" ;; file ) - file0=$val # no escape " for coverart and ffprobe - [[ $file0 == *".cue/track"* ]] && file0=$( dirname "$file0" ) + filenoesc=$val # no escape " for coverart and ffprobe + [[ $filenoesc == *".cue/track"* ]] && filenoesc=$( dirname "$filenoesc" ) file=${val//\"/\\\"} # escape " for json ;; random | repeat | single ) @@ -420,7 +420,7 @@ samplingLine() { -v quiet \ -show_entries format=bit_rate \ -of default=noprint_wrappers=1:nokey=1 \ - "/mnt/MPD/$file0" ) + "/mnt/MPD/$filenoesc" ) fi fi if (( $bitrate < 1000000 )); then @@ -428,7 +428,6 @@ samplingLine() { else [[ $bitdepth == dsd ]] && bitrate=$(( bitrate / 2 )) rate="$( awk "BEGIN { printf \"%.2f\n\", $bitrate / 1000000 }" ) Mbit/s" -# rate=$( echo "print $bitrate / 1000000" | perl )' Mbit/s' fi if [[ $bitdepth == dsd ]]; then @@ -436,7 +435,6 @@ samplingLine() { else [[ $bitdepth == 'N/A' && ( $ext == WAV || $ext == AIFF ) ]] && bitdepth=$(( bitrate / samplerate / 2 )) sample="$( awk "BEGIN { printf \"%.1f\n\", $samplerate / 1000 }" ) kHz" -# sample=$( echo "print $samplerate / 1000" | perl )' kHz' if [[ $bitdepth && ! $ext =~ ^(AAC|MP3|OGG|Radio)$ ]]; then sampling="$bitdepth bit $sample $rate" else # lossy has no bitdepth @@ -478,14 +476,13 @@ else hex=( $( hexdump -x -s$byte -n4 "/mnt/MPD/$file" | head -1 | tr -s ' ' ) ) dsd=$(( ${hex[1]} / 1100 * 64 )) # hex byte#57-58 - @1100:dsd64 bitrate=$( awk "BEGIN { printf \"%.2f\n\", $dsd * 44100 / 1000000 }" ) -# bitrate=$( echo "print $dsd * 44100 / 1000000" | perl ) sampling="DSD$dsd • $bitrate Mbit/s • $ext" else data=( $( ffprobe -v quiet -select_streams a:0 \ -show_entries stream=bits_per_raw_sample,sample_rate \ -show_entries format=bit_rate \ -of default=noprint_wrappers=1:nokey=1 \ - "/mnt/MPD/$file0" ) ) + "/mnt/MPD/$filenoesc" ) ) samplerate=${data[0]} bitdepth=${data[1]} bitrate=${data[2]} @@ -518,7 +515,7 @@ if [[ $ext != CD && ! $stream ]]; then coverart=$( $dirbash/status-coverart.sh "\ $AlbumArtist $Album -$file0" ) +$filenoesc" ) [[ $coverart ]] && coverart="${coverart:0:-4}.$date.${coverart: -3}" fi elapsedGet From 6a7edcdb03655b7060ff01f88270a7f3722a69f5 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 4 Sep 2022 14:01:51 +0700 Subject: [PATCH 14/19] u --- srv/http/settings/features.php | 4 ++-- srv/http/settings/networks.php | 17 +++++++++-------- srv/http/settings/relays.php | 2 +- srv/http/settings/system.php | 13 ++++++------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/srv/http/settings/features.php b/srv/http/settings/features.php index e6a84fd1a..9ac6f49d9 100644 --- a/srv/http/settings/features.php +++ b/srv/http/settings/features.php @@ -133,7 +133,7 @@ , 'disabled' => ( exec( 'systemctl -q is-active bluetooth && echo true' ) ? 'Bluetooth' : 'Equalizer' ).' is currently enabled.' , 'help' => <<< HTML CamillaDSP - A flexible cross-platform IIR and FIR engine for crossovers, room correction etc. -Settings: Features | +Settings: Features | HTML , 'exist' => file_exists( '/usr/bin/camilladsp' ) ] @@ -145,7 +145,7 @@ , 'disabled' => 'DSP is currently enabled.' , 'help' => <<< HTML Alsaequal - 10 band graphic equalizer with user presets. -Control: Features | +Control: Features | Presets: • Flat: All bands at 0dB • New: Adjust > Add > NAME > Save diff --git a/srv/http/settings/networks.php b/srv/http/settings/networks.php index 036c4b7d0..79f83b237 100644 --- a/srv/http/settings/networks.php +++ b/srv/http/settings/networks.php @@ -10,20 +10,19 @@
      
       	
      rAudio as sender:(or pairing non-audio devices) - • Pairing: + • Pair:   - On receiver - Turn on discovery / pairing mode -   - On rAudio - Search > Select receiver to pair - • Connecting: +   - On rAudio - Bluetooth  Search > Select to pair + • Connect:   - On receiver - power on / power off > connect / disconnect - • Receiver buttons: -   - Playback controls play pause previous next +   - Receiver buttons can be used to control playback rAudio as receiver: - • Pairing: + • Pair:   - On rAudio - System > Bluetooth setting - enable Discoverable by senders   - On sender - Search > Select rAudio to pair   - Forget / Remove should be done on both rAudio and sender - • Connecting: + • Connect:   - On sender - Select rAudio > connect / disconnect
      @@ -36,7 +35,9 @@ ] ); ?>
        -
        Avoid connecting to access points which signal less than 2 bars, audio quality and responsiveness are very likely to suffer. +
        + • Connect: Wi-Fi  Search > Select to connect + • Avoid connecting to access points which signal is less than 2 bars.
        diff --git a/srv/http/settings/relays.php b/srv/http/settings/relays.php index 5fe721a0a..756f45605 100644 --- a/srv/http/settings/relays.php +++ b/srv/http/settings/relays.php @@ -17,7 +17,7 @@ ?> Power on/off peripheral equipments -On/Off:  System |  +On/Off:  System |  • More info: +R GPIO • Can be enabled and run as a test without a connected relay module. diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 60bdba74a..ef45e559c 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -126,8 +126,6 @@ , 'disabled' => ( file_exists( '/srv/http/data/system/camilladsp' ) ? 'DSP is currently active.' : 'Bluetooth is currently connected.' ) , 'help' => <<< HTML Sampling 16bit - Only for Bluetooth receivers with fixed sampling - • Pairing: Networks > Bluetooth  - • Button on device can be used for play/pause HTML ] , [ @@ -139,10 +137,11 @@ , 'setting' => true , 'disabled' => 'Wi-Fi is currently connected.' , 'help' => <<< HTML -Auto start Access Point - On failed connection or no router -Country of Wi-Fi regulatory domain: - • 00 = Least common denominator settings, channels and transmit power are permitted in all countries. - • The connected router may override it to a certain country. + Settings + • Auto start Access Point - On failed connection or no router + • Country of Wi-Fi regulatory domain: +   - 00 = Least common denominator settings, channels and transmit power are permitted in all countries. +   - The connected router may override it to a certain country. HTML ] ]; @@ -334,7 +333,7 @@   • Samba: read only = no   • Windows: Everyone - Full Control • On each rAudio -   • Storage > Add to connect shared music on the server +   • Storage Add to connect shared music on the server   • Shared Data - Enable to connect the share. • Use data from this rAudio:   • Check only on rAudio with data to be used or to overwrite existing. From 47cb768c9c6eb4efcc8312ce5ae13033ef0434bd Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 4 Sep 2022 19:17:52 +0700 Subject: [PATCH 15/19] Update player-conf.sh --- srv/http/bash/settings/player-conf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/settings/player-conf.sh b/srv/http/bash/settings/player-conf.sh index 630b17771..0381f797b 100644 --- a/srv/http/bash/settings/player-conf.sh +++ b/srv/http/bash/settings/player-conf.sh @@ -135,7 +135,7 @@ fi linecdio=$( sed -n '/cdio_paranoia/ =' /etc/mpd.conf ) [[ $linecdio ]] && sed -i "$(( linecdio - 1 )),/^$/ d" /etc/mpd.conf -lastline=$(( $( sed -n '/^resampler/=' /etc/mpd.conf ) + 3 )) +lastline=$(( $( sed -n '/^audio_output/ =' /etc/mpd.conf | head -1 ) - 1 )) global=$( sed -n "1,$lastline p" /etc/mpd.conf | sed '/# custom0/,/# custom1/ d' ) if [[ -e $dirsystem/custom && -e $dirsystem/custom-global ]]; then custom=$( echo " From 238cb5100e4e240770ab3dee226007abfbd75a4f Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 4 Sep 2022 19:59:05 +0700 Subject: [PATCH 16/19] Update status.sh --- srv/http/bash/status.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index 3aa1bc1b9..6ea831b10 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -510,7 +510,7 @@ if [[ $coverart || ! $displaycover ]]; then # webradio $coverart exists outputStatus fi -if [[ $ext != CD && ! $stream ]]; then +if [[ $ext != CD && ! $stream && $AlbumArtist && $Album ]]; then getcover=1 coverart=$( $dirbash/status-coverart.sh "\ $AlbumArtist From 5b1d66c09c694d01d0a8259389b8ed09912bbf3e Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 4 Sep 2022 19:59:22 +0700 Subject: [PATCH 17/19] Update status.sh --- srv/http/bash/status.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index 6ea831b10..c365f7a59 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -510,7 +510,7 @@ if [[ $coverart || ! $displaycover ]]; then # webradio $coverart exists outputStatus fi -if [[ $ext != CD && ! $stream && $AlbumArtist && $Album ]]; then +if [[ $ext != CD && ! $stream && $AlbumArtist && $Album ]]; then getcover=1 coverart=$( $dirbash/status-coverart.sh "\ $AlbumArtist From dc611b3e18b8a9506e38a5b429781d88907be1d8 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 4 Sep 2022 20:09:15 +0700 Subject: [PATCH 18/19] u --- srv/http/bash/status-coverart.sh | 6 ++++-- srv/http/bash/status.sh | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/srv/http/bash/status-coverart.sh b/srv/http/bash/status-coverart.sh index 2393bc754..293c302b8 100644 --- a/srv/http/bash/status-coverart.sh +++ b/srv/http/bash/status-coverart.sh @@ -15,7 +15,7 @@ path="/mnt/MPD/$file" # found cover file localfile=$dirshm/local/$covername -[[ -e $localfile ]] && cat $localfile && exit +[[ -f $localfile ]] && cat $localfile && exit # found embedded embeddedname=$( echo ${filename%.*} | tr -d ' "`?/#&'"'" ) embeddedfile=$dirshm/embedded/$embeddedname.jpg @@ -30,7 +30,9 @@ coverfile=$( ls -1X "$path"/cover.{gif,jpg,png} 2> /dev/null | head -1 ) | egrep -i '/album\....$|cover\....$|/folder\....$|/front\....$' \ | head -1 ) if [[ $coverfile ]]; then - php -r "echo rawurlencode( '${coverfile//\'/\\\'}' );" | tee $localfile # rawurlencode - local path only + coverfile=$( php -r "echo rawurlencode( '${coverfile//\'/\\\'}' );" ) + echo $coverfile + [[ -f $localfile ]] && echo $coverfile > $localfile # rawurlencode - local path only $dirbash/cmd.sh coverfileslimit exit fi diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index c365f7a59..3aa1bc1b9 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -510,7 +510,7 @@ if [[ $coverart || ! $displaycover ]]; then # webradio $coverart exists outputStatus fi -if [[ $ext != CD && ! $stream && $AlbumArtist && $Album ]]; then +if [[ $ext != CD && ! $stream ]]; then getcover=1 coverart=$( $dirbash/status-coverart.sh "\ $AlbumArtist From 8ba0fabf0a02d48ea2b910f34d5d482ebb5cf398 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 4 Sep 2022 20:12:16 +0700 Subject: [PATCH 19/19] Update player.php --- srv/http/settings/player.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/settings/player.php b/srv/http/settings/player.php index 776cbd08a..acf9a5df9 100644 --- a/srv/http/settings/player.php +++ b/srv/http/settings/player.php @@ -179,7 +179,7 @@ HTML ] , [ - 'label' => 'SoXR resampler' + 'label' => 'SoXR Resampler' , 'id' => 'soxr' , 'sublabel' => 'custom settings' , 'setting' => true