Skip to content

Commit

Permalink
Merge pull request #1110 from rern/UPDATE
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
rern authored Nov 23, 2022
2 parents 247452c + 3969b03 commit 567c49a
Show file tree
Hide file tree
Showing 21 changed files with 234 additions and 205 deletions.
22 changes: 18 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,28 @@ alias=r1

. /srv/http/bash/addons.sh

# 20221122
file=/etc/udev/rules.d/ntfs3.rules
if [[ -e $file ]]; then
rm $file
# 20221123
mv /etc/udev/rules.d/ntfs{3,}.rules &> /dev/null
file=/etc/udev/rules.d/ntfs.rules
if [[ ! -e $file ]]; then
cat << 'EOF' > $file
ACTION=="add", \
SUBSYSTEM=="block", \
ENV{ID_FS_TYPE}=="ntfs", \
ENV{ID_FS_TYPE}="ntfs3", \
RUN+="/srv/http/bash/settings/system.sh usbconnect"
ACTION=="remove", \
SUBSYSTEM=="block", \
ENV{ID_FS_TYPE}=="ntfs", \
ENV{ID_FS_TYPE}="ntfs3", \
RUN+="/srv/http/bash/settings/system.sh usbremove"
EOF
udevadm control --reload-rules
udevadm trigger
fi

# 20221122
sed -i '/shairport-sync/ d' /etc/pacman.conf
veropenssl=$( pacman -Q openssl | cut -d' ' -f2 | cut -c 1 )
vershairport=$( pacman -Q shairport-sync | cut -d' ' -f2 | cut -c 1 )
Expand Down
6 changes: 3 additions & 3 deletions srv/http/assets/js/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ function displaySave( keys ) {
var display = JSON.parse( JSON.stringify( G.display ) );
keys.forEach( ( k, i ) => display[ k ] = values[ i ] );
[ 'audiocd', 'color', 'equalizer', 'logout', 'order',
'relays', 'screenoff', 'snapclient', 'snapclientactive', 'volumenone' ].forEach( item => delete display[ item ] );
'relays', 'screenoff', 'snapclient', 'volumenone' ].forEach( item => delete display[ item ] );
bash( [ 'displaysave', JSON.stringify( display ) ] );
}
function displaySubMenu() {
Expand Down Expand Up @@ -1349,14 +1349,14 @@ function setButtonControl() {
}
function setButtonOptions() {
$( '#relays' ).toggleClass( 'on', G.status.relayson );
$( '#snapclient' ).toggleClass( 'on', G.status.player === 'snapcast' || G.display.snapclientactive );
$( '#snapclient' ).toggleClass( 'on', G.status.player === 'snapcast' );
$( '#modeicon i, #timeicon i' ).addClass( 'hide' );
var timevisible = $time.is( ':visible' );
var prefix = timevisible ? 'ti' : 'i';
$( '#'+ prefix +'-btsender' ).toggleClass( 'hide', ! G.status.btreceiver );
$( '#'+ prefix +'-relays' ).toggleClass( 'hide', ! G.status.relayson );
$( '#'+ prefix +'-stoptimer' ).toggleClass( 'hide', ! G.status.stoptimer );
$( '#'+ prefix +'-snapclient' ).toggleClass( 'hide', ! G.display.snapclientactive );
$( '#'+ prefix +'-snapclient' ).toggleClass( 'hide', ! G.status.snapclient );
if ( ! G.status.stream && G.status.player === 'mpd' ) {
if ( $( '#play-group' ).is( ':visible' ) ) {
$( '#random' ).toggleClass( 'active', G.status.random );
Expand Down
7 changes: 4 additions & 3 deletions srv/http/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,13 @@ $( '#settings' ).on( 'click', '.submenu', function() {
case 'snapclient':
var active = $( this ).hasClass( 'on' );
if ( active ) {
if ( G.display.snapclientactive ) {
if ( G.status.snapclient ) {
bash( '/srv/http/bash/snapcast.sh stop' );
} else {
$( '#stop' ).click();
}
} else {
$( '#stop' ).click();
bash( '/srv/http/bash/snapcast.sh start', data => {
bannerHide();
if ( data == -1 ) {
Expand Down Expand Up @@ -1048,11 +1049,11 @@ $( '.btn-cmd' ).click( function() {
$( '#elapsed, #progress' ).empty();
vu();
}
if ( G.playback && G.status.stream ) {
/* if ( G.playback && G.status.stream ) {
[ 'Artist', 'Title', 'Album', 'coverart' ].forEach( el => G.status[ el ] = '' );
setInfo();
setCoverart();
}
}*/
} else if ( G.playlist ) {
$( '#pl-list .song' ).empty();
$( '#pl-list .li1' ).find( '.name, .song' ).css( 'max-width', '' );
Expand Down
7 changes: 7 additions & 0 deletions srv/http/assets/js/passive.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ function psOption( data ) {
return
}

if ( 'snapclient' in data ) {
G.status.snapclient = data.snapclient;
var prefix = $time.is( ':visible' ) ? 'ti' : 'i';
$( '#'+ prefix +'-snapclient' ).toggleClass( 'hide', ! G.status.snapclient );
return
}

var option = Object.keys( data )[ 0 ];
G.status[ option ] = Object.values( data )[ 0 ];
setButtonOptions();
Expand Down
71 changes: 35 additions & 36 deletions srv/http/assets/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $( '.playback' ).click( function() {
}
} );
$( '#setting-btreceiver' ).click( function() {
bash( [ 'volumebtget' ], voldb => {
bash( [ 'volumegetbt' ], voldb => {
var voldb = voldb.split( ' ' );
var vol = voldb[ 0 ];
var db = voldb[ 1 ];
Expand All @@ -28,12 +28,12 @@ $( '#setting-btreceiver' ).click( function() {
$( '#infoRange input' ).on( 'click input', function() {
bash( 'amixer -MD bluealsa -q sset "'+ G.btaplayname +'" '+ $( this ).val() +'%' );
} ).on( 'touchend mouseup keyup', function() {
bash( [ 'volumebt', G.btaplayname, $( this ).val() ] );
bash( [ 'volumepushbt' ] );
} );
}
, buttonnoreset : 1
, buttonlabel : '<i class="fa fa-set0"></i>0dB'
, button : () => bash( [ 'volumebt', G.btaplayname, '0dB' ] )
, button : () => bash( [ 'volume0dbbt' ] )
, okno : 1
} );
} );
Expand All @@ -49,7 +49,7 @@ $( '#hwmixer' ).change( function() {
} );
$( '#setting-hwmixer' ).click( function() {
var novolume = device.mixertype === 'none';
bash( [ 'volumeget', 'db' ], voldb => {
bash( [ 'volumeget' ], voldb => {
var voldb = voldb.split( ' ' );
var vol = voldb[ 0 ];
var db = voldb[ 1 ];
Expand Down Expand Up @@ -81,7 +81,7 @@ $( '#setting-hwmixer' ).click( function() {
$( '#infoRange input' ).on( 'click input keyup', function() {
bash( 'amixer -c '+ card +' -Mq sset "'+ control +'" '+ $( this ).val() +'%' );
} ).on( 'touchend mouseup keyup', function() {
bash( [ 'volumeget', 'push' ] );
bash( [ 'volumepush' ] );
} );
$( '.extrabtn:eq( 0 ), #infoOk' ).addClass( 'hide' );
}
Expand All @@ -91,7 +91,7 @@ $( '#setting-hwmixer' ).click( function() {
, button : [ toggle, toggle ]
, oklabel : 'OK'
, ok : () => {
bash( [ 'volume0db', card, control ] );
bash( [ 'volume0db' ] );
toggle();
}
} );
Expand Down Expand Up @@ -392,6 +392,13 @@ function renderPage() {
+'<i class="fa fa-album gr"></i>&ensp;'+ ( G.counts.album || 0 ).toLocaleString() +'<wide>&emsp; '
+'<i class="fa fa-webradio gr"></i>&ensp;'+ ( G.counts.webradio || 0 ).toLocaleString() +'</wide>';
$( '#statusvalue' ).html( htmlstatus );
if ( G.btaplayname ) {
$( '#divbtreceiver' ).removeClass( 'hide' );
$( '#btaplayname' ).html( '<option>'+ G.btaplayname.replace( / - A2DP$/, '' ) +'</option>' );
$( '#setting-btreceiver' ).removeClass( 'hide' );
} else {
$( '#divbtreceiver' ).addClass( 'hide' );
}
if ( G.asoundcard !== -1 ) {
device = G.devices[ G.asoundcard ];
G.resampled = G.crossfade || G.normalization || G.replaygain || G.camilladsp || G.equalizer || G.soxr;
Expand All @@ -400,40 +407,32 @@ function renderPage() {
$.each( G.devices, ( i, el ) => {
if ( el.aplayname !== 'Loopback' ) htmldevices += '<option value="'+ el.card +'">'+ el.name +'</option>';
} );
if ( G.btaplayname ) {
$( '#divaudiooutput, #divhwmixer, #divmixertype, #divbitperfect' ).addClass( 'hide' );
$( '#divbtreceiver' ).removeClass( 'hide' );
$( '#btaplayname' ).html( '<option>'+ G.btaplayname.replace( / - A2DP$/, '' ) +'</option>' );
$( '#setting-btreceiver' ).removeClass( 'hide' );
} else {
$( '#divaudiooutput, #divhwmixer, #divmixertype, #divbitperfect' ).removeClass( 'hide' );
$( '#divbtreceiver' ).addClass( 'hide' );
$( '#audiooutput' )
.html( htmldevices )
.val( G.asoundcard );
var htmlhwmixer = device.mixermanual ? '<option value="auto">Auto</option>' : '';
if ( 'mixerdevices' in device ) {
device.mixerdevices.forEach( mixer => htmlhwmixer += '<option value="'+ mixer +'">'+ mixer +'</option>' );
}
$( '#hwmixer' )
.html( htmlhwmixer )
.val( device.hwmixer );
var htmlmixertype = '<option value="none">None / 0dB</option>';
if ( device.mixers ) htmlmixertype += '<option value="hardware">Mixer device</option>';
htmlmixertype += '<option value="software">MPD software</option>';
$( '#mixertype' )
.html( htmlmixertype )
.val( device.mixertype );
$( '#setting-hwmixer' ).toggleClass( 'hide', device.mixers === 0 );
$( '#novolume' ).prop( 'checked', G.novolume );
$( '#divdop' ).toggleClass( 'disabled', device.aplayname.slice( 0, 7 ) === 'bcm2835' );
$( '#dop' ).prop( 'checked', G.dop );
$( '#ffmpeg' ).toggleClass( 'disabled', G.dabradio );
$( '#divaudiooutput, #divhwmixer, #divmixertype, #divbitperfect' ).removeClass( 'hide' );
$( '#audiooutput' )
.html( htmldevices )
.val( G.asoundcard );
var htmlhwmixer = device.mixermanual ? '<option value="auto">Auto</option>' : '';
if ( 'mixerdevices' in device ) {
device.mixerdevices.forEach( mixer => htmlhwmixer += '<option value="'+ mixer +'">'+ mixer +'</option>' );
}
$( '#hwmixer' )
.html( htmlhwmixer )
.val( device.hwmixer );
var htmlmixertype = '<option value="none">None / 0dB</option>';
if ( device.mixers ) htmlmixertype += '<option value="hardware">Mixer device</option>';
htmlmixertype += '<option value="software">MPD software</option>';
$( '#mixertype' )
.html( htmlmixertype )
.val( device.mixertype );
$( '#setting-hwmixer' ).toggleClass( 'hide', device.mixers === 0 );
$( '#novolume' ).prop( 'checked', G.novolume );
$( '#divdop' ).toggleClass( 'disabled', device.aplayname.slice( 0, 7 ) === 'bcm2835' );
$( '#dop' ).prop( 'checked', G.dop );
$( '#ffmpeg' ).toggleClass( 'disabled', G.dabradio );
$( '#divaudiooutput div' ).eq( 0 ).html( G.camilladsp ? '<i class="fa fa-camilladsp"></i>' : 'Device' );
}
if ( $( '#infoRange .value' ).length ) {
var cmd = I.title === 'Mixer Device Volume' ? [ 'volumeget', 'db' ] : [ 'volumebtget' ];
var cmd = I.title === 'Mixer Device Volume' ? [ 'volumeget' ] : [ 'volumegetbt' ];
bash( cmd, voldb => {
var voldb = voldb.split( ' ' );
var vol = voldb[ 0 ];
Expand Down
95 changes: 39 additions & 56 deletions srv/http/bash/cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,38 +155,35 @@ urldecode() { # for webradio url to filename
echo -e "${_//%/\\x}"
}
volumeGet() {
if [[ -e $dirshm/btreceiver ]]; then
control=$( < $dirshm/btreceiver )
for i in {1..5}; do # takes some seconds to be ready
volume=$( amixer -MD bluealsa 2> /dev/null | awk -F'[[%]' '/%.*dB/ {print $2;exit}' )
[[ $volume ]] && break
sleep 1
done
return
fi
[[ -e $dirshm/btreceiver ]] && volumeGetBt && return

[[ -e $dirshm/nosound ]] && volume=-1 && return
[[ -e $dirshm/nosound ]] && echo -1 && return

mixertype=$( sed -E -n '/type *"alsa"/,/mixer_type/ {/mixer_type/ {s/^.*"(.*)"/\1/; p}}' $dirmpdconf/output.conf )
if [[ -e $dirsystem/snapclientserver ]]; then
mixertype=
else
mixertype=$( sed -E -n '/type *"alsa"/,/mixer_type/ {/mixer_type/ {s/^.*"(.*)"/\1/; p}}' $dirmpdconf/output.conf )
fi
if [[ $( < $dirshm/player ) == mpd && $mixertype == software ]]; then
volume=$( mpc volume | cut -d: -f2 | tr -d ' %n/a' )
mpc volume | cut -d: -f2 | tr -d ' %n/a'
else
card=$( < $dirsystem/asoundcard )
if [[ ! -e $dirshm/amixercontrol ]]; then
volume=100
control=$( cat $dirshm/amixercontrol 2> /dev/null )
if [[ ! $control ]]; then
echo 100
else
control=$( < $dirshm/amixercontrol )
voldb=$( amixer -c $card -M sget "$control" | awk -F'[[%dB]' '/%.*dB/ {print $2" "$4;exit}' )
if [[ $voldb ]]; then
volume=${voldb/ *}
db=${voldb/* }
else
volume=$( amixer -MD bluealsa 2> /dev/null | awk -F'[[%]' '/%.*dB/ {print $2;exit}' )
[[ ! $volume ]] && volume=100
fi
amixer -c $card -M sget "$control" | grep -m1 % | sed -E 's/.*\[(.*)%].*/\1/'
fi
fi
}
volumeGetBt() {
control=$( < $dirshm/btreceiver )
for i in {1..5}; do # takes some seconds to be ready
val=$( amixer -MD bluealsa 2> /dev/null | grep -m1 % | sed -E 's/.*\[(.*)%].*/\1/' )
[[ $val ]] && echo $val && break
sleep 1
done
}
volumeSet() {
current=$1
target=$2
Expand Down Expand Up @@ -752,6 +749,21 @@ mpcplayback )
killall cava &> /dev/null
[[ -e $dirshm/scrobble ]] && scrobbleOnStop $pos
fi
[[ ! -e $dirsystem/snapclientserver ]] && exit

if [[ $command == play ]]; then
action=start
active=true
sleep 2 # fix stutter
touch $dirshm/snapclient
else
action=stop
active=false
rm $dirshm/snapclient
fi
systemctl $action snapclient
pushstream option '{"snapclient":'$active'}'
pushstream refresh '{"page":"features","snapclientactive":'$active'}'
;;
mpcprevnext )
command=${args[1]}
Expand Down Expand Up @@ -863,7 +875,6 @@ ordersave )
;;
playerstart )
player=${args[1]}
[[ $player == bluetooth ]] && volumeGet save
mpc -q stop
stopRadio
echo $player > $dirshm/player
Expand Down Expand Up @@ -897,11 +908,7 @@ playerstop )
systemctl restart bluetooth
;;
snapcast )
systemctl stop snapclient
$dirsettings/player-conf.sh
ip=$( ipAddress )
sshCommand $( < $dirshm/serverip ) $dirbash/snapcast.sh remove $ip
rm $dirshm/serverip
$dirbash/snapcast.sh stop
;;
spotify )
rm -f $dirshm/spotify/start
Expand Down Expand Up @@ -1064,7 +1071,7 @@ volume ) # no args = toggle mute / unmute
control=${args[4]}
[[ $current == drag ]] && volumeSetAt $target $card "$control" && exit

[[ ! $current ]] && volumeGet && current=$volume
[[ ! $current ]] && current=$( volumeGet )
filevolumemute=$dirsystem/volumemute
if [[ $target > 0 ]]; then # set
rm -f $filevolumemute
Expand All @@ -1082,34 +1089,11 @@ volume ) # no args = toggle mute / unmute
fi
volumeSet $current $target $card "$control"
;;
volume0db )
player=$( < $dirshm/player )
volumeGet
amixer -c $card -Mq sset "$control" 0dB
;;
volumecontrolget )
volumeGet
echo $card^$control^$volume # $control not last - keep trailing space if any
;;
volumeget )
type=${args[1]}
volumeGet
if [[ $type == db ]]; then
echo $volume $db
elif [[ $type == push ]]; then
pushstream volume '{"val":'$volume',"db":"'$db'"}'
else
echo $volume
fi
;;
volumepushstream )
[[ -e $dirshm/btreceiver ]] && sleep 1
volumeGet
pushstream volume '{"val":'$volume'}'
[[ $control ]] && alsactl store
;;
volumesave )
volumeGet save
pushstream volume '{"val":'$( volumeGet )'}'
;;
volumeupdown )
updn=${args[1]}
Expand All @@ -1124,8 +1108,7 @@ volumeupdown )
mpc -q volume ${updn}1
fi
fi
volumeGet
pushstreamVolume updn $volume
pushstreamVolume updn $( volumeGet )
;;
webradioadd )
dir=${args[1]}
Expand Down
2 changes: 1 addition & 1 deletion srv/http/bash/mpdidle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mpc idleloop | while read changed; do
echo $s > $dirshm/vol
else
rm -f $dirshm/vol
pushstream volume '{"val":'$( $dirbash/cmd.sh volumeget )'}'
$dirbash/cmd.sh volumepushstream
fi
done ) &> /dev/null &
fi
Expand Down
Loading

0 comments on commit 567c49a

Please sign in to comment.