diff --git a/srv/http/assets/js/context.js b/srv/http/assets/js/context.js index 9f21f6251..0e858fa26 100644 --- a/srv/http/assets/js/context.js +++ b/srv/http/assets/js/context.js @@ -609,7 +609,7 @@ $( '.contextmenu a, .contextmenu .submenu' ).click( function() { case 'remove': G.contextmenu = 1; setTimeout( function() { G.contextmenu = 0 }, 500 ); - plRemove( G.list.li ); + playlistRemove( G.list.li ); return case 'savedpladd': if ( G.playlist ) { diff --git a/srv/http/assets/js/function.js b/srv/http/assets/js/function.js index fb781d758..7c13ac2e5 100644 --- a/srv/http/assets/js/function.js +++ b/srv/http/assets/js/function.js @@ -957,8 +957,8 @@ function playlistFilter() { $( '#pl-search-close' ).empty(); } } -function plRemove( $li ) { - if ( G.status.pllength === 1 ) { +function playlistRemove( $li ) { + if ( $( '#pl-list li' ).length === 1 ) { bash( [ 'plremove' ] ); } else { var total = $( '#pl-time' ).data( 'time' ) - $li.find( '.time' ).data( 'time' ); @@ -978,22 +978,21 @@ function plRemove( $li ) { $count.prev().addBack().remove(); } } - var i = $li.index() + 1; + var poscurent = ''; + var pos = $li.index() + 1; if ( $li.hasClass( 'active' ) ) { if ( $li.next().is( 'li' ) ) { - var activenext = i; + poscurent = pos; $li.next().addClass( 'active' ); } else { - var activenext = i - 1; + poscurent = pos - 1; $li.prev().addClass( 'active' ); } - } else { - var activenext = ''; } - bash( [ 'plremove', i, activenext ] ); - $( '#pl-list li .pos' ).slice( i ).each( function() { - $( this ).text( i ); - i++ + bash( [ 'plremove', pos, poscurent ] ); + $( '#pl-list li .pos' ).slice( pos ).each( function() { + $( this ).text( pos ); + pos++ } ); $li.remove(); } diff --git a/srv/http/assets/js/main.js b/srv/http/assets/js/main.js index 6ed63b516..1d9e35f72 100644 --- a/srv/http/assets/js/main.js +++ b/srv/http/assets/js/main.js @@ -462,7 +462,7 @@ $( '#playback' ).click( function() { switchPage( 'playback' ); } } ); -$( '#playlist' ).click( function() { +$( '#playlist, #button-playlist' ).click( function() { if ( !G.local ) G.pladd = {} if ( G.playlist ) { if ( G.savedlist || G.savedplaylist ) getPlaylist(); @@ -1770,9 +1770,6 @@ $( '.page' ).on( 'click', '.index a', function() { $( 'html, body' ).scrollTop( scrollT - ( $( '#bar-top' ).is( ':visible' ) ? 80 : 40 ) ); } ); // PLAYLIST ///////////////////////////////////////////////////////////////////////////////////// -$( '#button-playlist' ).click( function() { - $( '#playlist' ).click(); -} ); $( '#pl-manage i' ).click( function() { menuHide(); } ); @@ -2013,7 +2010,7 @@ $( '#pl-list' ).on( 'click', 'li', function( e ) { $menu.find( '.wrsave' ).toggleClass( 'hide', !notsaved ); contextmenuScroll( $menu, $thisli.offset().top + 48 ); } ).on( 'click', '.pl-remove', function() { // remove from playlist - plRemove( $( this ).parent() ); + playlistRemove( $( this ).parent() ); } ); $( '#pl-savedlist' ).on( 'click', 'li', function( e ) { menuHide(); diff --git a/srv/http/assets/js/player.js b/srv/http/assets/js/player.js index 5ea34dbd7..b50b1718b 100644 --- a/srv/http/assets/js/player.js +++ b/srv/http/assets/js/player.js @@ -364,13 +364,9 @@ function playbackIcon() { function renderPage() { playbackIcon(); var htmlstatus = G.version +'
' - if ( G.counts ) { - htmlstatus += ' '+ G.counts.song.toLocaleString() +'  ' - +' '+ G.counts.album.toLocaleString() +'  ' - +' '+ G.counts.webradio.toLocaleString() +''; - } else { - htmlstatus += 'Updating ...'; - } + +' '+ ( G.counts.song || 0 ).toLocaleString() +'  ' + +' '+ ( G.counts.album || 0 ).toLocaleString() +'  ' + +' '+ ( G.counts.webradio || 0 ).toLocaleString() +''; if ( !G.active ) htmlstatus += '
 MPD not running' $( '#statusvalue' ).html( htmlstatus ); if ( G.asoundcard != -1 ) { diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 29b2f33da..2e57aacf4 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -868,7 +868,7 @@ function infoMount( values ) { if ( !values || values.length === 8 ) { var htmlname = `\ As: NAS/ - + `; var chktext = 'Update Library on mount' } else { @@ -889,8 +889,8 @@ ${ htmlname } Server IP -Share name - +Share name + User @@ -913,24 +913,39 @@ ${ htmlname } , beforeshow : function() { $( '#infoContent td' ).eq( 0 ).css( 'width', 90 ); $( '#infoContent td' ).eq( 1 ).css( 'width', 230 ); - var $sharelabel = $( '#sharename td' ).eq( 0 ); - var $share = $( '#sharename input' ); - var $guest = $( '.guest' ); + var $share = $( '#share' ); function hideOptions( type ) { + $share.val( '' ); if ( type === 'nfs' ) { - $sharelabel.text( 'Share path' ); - $guest.addClass( 'hide' ); - $share.val( $share.val() || '/' ); + $( '#sharelabel' ).text( 'Share path' ); + $( '.guest' ).addClass( 'hide' ); + $share.attr( 'placeholder', '/path/to/share' ); } else { - $sharelabel.text( 'Share name' ); - $guest.removeClass( 'hide' ); - $share.val( $share.val().replace( /\//g, '' ) ); + $( '#sharelabel' ).text( 'Share name' ); + $( '.guest' ).removeClass( 'hide' ); + $share.attr( 'placeholder', 'sharename' ); } } hideOptions( values ? values[ 0 ] : 'cifs' ); $( '#infoContent input:radio' ).change( function() { hideOptions( $( this ).val() ); } ); + var $mountpoint = $( '#mountpoint' ); + $mountpoint.on( 'keyup paste', function() { + setTimeout( function() { + $mountpoint.val( $mountpoint.val().replace( /\//g, '' ) ); + }, 0 ); + } ); + $share.on( 'keyup paste', function() { + setTimeout( function() { + var sharename = $share.val(); + if ( $( '#infoContent input[type=radio]:checked' ).val() === 'cifs' ) { + $share.val( sharename.replace( /[\/\\]/g, '' ) ); + } else { + if ( sharename[ 0 ] !== '/' ) $share.val( '/'+ sharename ); + } + }, 0 ); + } ); } , cancel : function() { if ( shareddata ) $( '#shareddata' ).prop( 'checked', false ); diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index 9c504babc..8a1ae9de0 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -1081,10 +1081,10 @@ plorder ) ;; plremove ) pos=${args[1]} - activenext=${args[2]} + posprev=${args[2]} if [[ $pos ]]; then mpc -q del $pos - [[ $activenext ]] && mpc -q play $activenext && mpc -q stop + [[ $posprev ]] && mpc -q play $posprev && mpc -q stop else mpc -q clear fi @@ -1373,7 +1373,7 @@ webradiodelete ) path=$dirdata/$type [[ $dir ]] && path+="/$dir" rm -f "$path/$urlname" - [[ -z $( find $dir -name $urlname ) ]] && rm -f "$path/img/$urlname"{,-thumb}.* + [[ ! $( find $dir -name $urlname ) ]] && rm -f "$path/img/$urlname"{,-thumb}.* webradioCount $type ;; wrdirdelete ) diff --git a/srv/http/bash/dab-scan.sh b/srv/http/bash/dab-scan.sh index 25be930f0..b7f105464 100644 --- a/srv/http/bash/dab-scan.sh +++ b/srv/http/bash/dab-scan.sh @@ -32,7 +32,7 @@ for service in "${services[@]}"; do echo "\ $name 48 kHz 160 kbit/s -" > "$dirdabradio/$ensemble/rtsp:||$host|$channel_id" +" > "$dirdabradio/$ensemble/rtsp:||$host:8554|$channel_id" list+="\ $channel_id: runOnDemand: /srv/http/bash/dab-start.sh $id $channel \$RTSP_PORT \$RTSP_PATH diff --git a/srv/http/bash/dab-start.sh b/srv/http/bash/dab-start.sh index 42775b000..f56c7d932 100644 --- a/srv/http/bash/dab-start.sh +++ b/srv/http/bash/dab-start.sh @@ -21,17 +21,17 @@ dab-rtlsdr-3 \ DABPID=$! ffmpeg \ + -re \ + -stream_loop -1 \ -ac 2 \ -ar 48000 \ - -b:a 160k \ - -c:a aac \ -f s16le \ - -f rtsp rtsp://localhost:$3/$4 \ -i $MYPIPE \ - -metadata title="DAB Radio" \ - -readrate 1 \ - -stream_loop -1 \ -vn \ + -b:a 160k \ + -c:a aac \ + -metadata title="DAB Radio" \ + -f rtsp rtsp://localhost:$3/$4 \ &> /dev/null & FFMPID=$! diff --git a/srv/http/bash/settings/system-datareset.sh b/srv/http/bash/settings/system-datareset.sh index 565b41fd6..d0fe48a8f 100644 --- a/srv/http/bash/settings/system-datareset.sh +++ b/srv/http/bash/settings/system-datareset.sh @@ -147,8 +147,10 @@ sed -i -e -E '/^auto_update|^audio_buffer_size| #custom$/ d } ' /etc/mpd.conf if [[ ! -e $dirmpd/counts ]]; then - webradio=$( find -L $dirwebradio -type f ! -path '*/img/*' | wc -l ) - echo '{ "webradio": '$webradio' }' > $dirmpd/counts + echo '{ + "playlists" : '$( ls -1 $dirplaylists | wc -l )' +, "webradio" : '$( find -L $dirwebradio -type f ! -path '*/img/*' | wc -l )' +}' > $dirmpd/counts fi usermod -a -G root http # add user http to group root to allow /dev/gpiomem access diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index b1e0fb1ec..5bc50a6b3 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -158,6 +158,11 @@ databackup ) fi mkdir -p $dirconfig/var/lib cp -r /var/lib/bluetooth $dirconfig/var/lib &> /dev/null + xinitrcfiles=$( ls /etc/X11/xinit/xinitrc.d | grep -v 50-systemd-user.sh ) + if [[ $xinitrcfiles ]]; then + mkdir -p $dirconfig/etc/X11/xinit + cp -r /etc/X11/xinit/xinitrc.d $dirconfig/etc/X11/xinit + fi services='bluetooth hostapd localbrowser mpdscribble@mpd powerbutton shairport-sync smb snapclient snapserver spotifyd upmpdcli' for service in $services; do @@ -190,18 +195,17 @@ datarestore ) rm -f $dirsystem/{color,relays,soundprofile} # system bsdtar -xpf $backupfile -C /srv/http - # temp + # temp 20220808 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if [[ -e $dirdata/webradios ]]; then mv $dirdata/webradio{s,} mv $dirdata/{webradiosimg,webradio/img} fi - + # temp 20220808 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< uuid1=$( head -1 /etc/fstab | cut -d' ' -f1 ) uuid2=${uuid1:0:-1}2 sed -i "s/root=.* rw/root=$uuid2 rw/; s/elevator=noop //" $dirconfig/boot/cmdline.txt sed -i "s/^PARTUUID=.*-01 /$uuid1 /; s/^PARTUUID=.*-02 /$uuid2 /" $dirconfig/etc/fstab - rm -f $dirconfig/etc/{shairport-sync,spotifyd}.conf # temp: for ealier version cp -rf $dirconfig/* / [[ -e $dirsystem/enable ]] && systemctl -q enable $( cat $dirsystem/enable ) [[ -e $dirsystem/disable ]] && systemctl -q disable $( cat $dirsystem/disable ) @@ -219,8 +223,6 @@ datarestore ) rm -rf $backupfile $dirconfig $dirsystem/{enable,disable,hostname,netctlprofile,timezone} [[ -e $dirsystem/crossfade ]] && mpc crossfade $( cat $dirsystem/crossfade.conf ) rmdir /mnt/MPD/NAS/* &> /dev/null - chown -R http:http /srv/http - chown mpd:audio $dirmpd/mpd* &> /dev/null readarray -t mountpoints <<< $( grep /mnt/MPD/NAS /etc/fstab | awk '{print $2}' | sed 's/\\040/ /g' ) if [[ $mountpoints ]]; then for mountpoint in $mountpoints; do @@ -240,36 +242,7 @@ datarestore ) done fi fi - - # temp 20220312 ### - readarray -t plfiles <<< $( ls -I '*.*' $dirplaylists ) - if [[ $plfiles ]]; then - echo -e "\n\e[38;5;6m\e[48;5;6m . \e[0m Convert saved playlists ..." - for name in "${plfiles[@]}"; do - echo $name - plfile="$dirplaylists/$name" - list=$( grep '"file":' "$plfile" | sed 's/^\s*"file": "//; s/",$//; s/\\//g' ) - if grep -q '^\s*"Range": ' "$plfile"; then - readarray -t file_track <<< $( grep -B1 -A5 '"Range":' "$plfile" \ - | egrep '"file":|"Track":' \ - | sed -E 's/^\s*"file": "|^\s*"Track": //; s/",$|,$//; s/\\//g' ) - iL=${#file_track[@]} - for (( i=0; i < iL; i++ )); do - track=000${file_track[$(( i + 1 ))]} - file=${file_track[i]} - filecue="${file%.*}.cue/track${track: -4}" - list=$( sed "s|$file|$filecue|" <<< "$list" ) - (( i++ )) - done - fi - echo "$list" > "$plfile.m3u" - rm "$plfile" - done - fi - # temp 20220312 ### - - chown -R http:http /srv/http/{assets,bash,settings} - chmod 755 /srv/http/* $dirbash/* /srv/http/settings/* + $dirbash/cmd.sh dirpermissions [[ -e $dirsystem/color ]] && $dirbash/cmd.sh color $dirbash/cmd.sh power$'\n'reboot ;; diff --git a/srv/http/bash/startup.sh b/srv/http/bash/startup.sh index dec87cb97..1a9918543 100644 --- a/srv/http/bash/startup.sh +++ b/srv/http/bash/startup.sh @@ -140,9 +140,7 @@ if [[ -e $dirsystem/hddspindown ]]; then fi if [[ ! $shareddata && ! -e $dirmpd/mpd.db ]]; then - if [[ ! -z $( ls /mnt/MPD/NAS ) || ! -z $( ls /mnt/MPD/SD ) || ! -z $( ls /mnt/MPD/USB ) ]]; then - $dirbash/cmd.sh$'\n'rescan - fi + $dirbash/cmd.sh$'\n'rescan elif [[ -e $dirmpd/updating ]]; then $dirbash/cmd.sh$'\n'"$( cat $dirmpd/updating )" elif [[ -e $dirmpd/listing || ! -e $dirmpd/counts ]]; then diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index 3aa1bc1b9..95b409d32 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -349,7 +349,7 @@ $radiosampling" > $dirshm/radio stationcover=$filenoext.$date.jpg fi fi - status=$( egrep -v '^, *"state"|^, *"webradio"' <<< "$status" ) + status=$( egrep -v '^, *"state"|^, *"webradio".*true|^, *"webradio".*false' <<< "$status" ) ######## status+=' , "Album" : "'$Album'" diff --git a/srv/http/bash/xinitrc b/srv/http/bash/xinitrc index 559bb7009..b24c0aab3 100644 --- a/srv/http/bash/xinitrc +++ b/srv/http/bash/xinitrc @@ -2,12 +2,9 @@ export XDG_CACHE_HOME="/tmp/.cache" -if [ -d /etc/X11/xinit/xinitrc.d ]; then - for f in /etc/X11/xinit/xinitrc.d/*; do - [ -x "$f" ] && . "$f" - done - unset f -fi +for file in /etc/X11/xinit/xinitrc.d/*; do + . "$file" +done . /srv/http/data/system/localbrowser.conf