Added an icon and fixed shuffle on BSD systems.

This commit is contained in:
iAmInAction 2022-07-20 09:40:06 +02:00 committed by GitHub
parent 038e377fb2
commit d6f818743b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

BIN
midify.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -10,7 +10,8 @@
# Change the default midi player. # Change the default midi player.
# 1 = timidity # 1 = timidity
# 2 = pioplemidi-cli # 2 = pioplemidi-cli
# 3 = custom command # 3 = playmidi (OSX Midi player)
# 4 = custom command
MIDIPLAYER=1 MIDIPLAYER=1
# Custom MIDI player command (in case 3 is selected): # Custom MIDI player command (in case 3 is selected):
@ -39,11 +40,23 @@ mkdir $TEMP
# Define Functions: # Define Functions:
# Generate random number in range:
genrandinrange () {
if command -v jot &> /dev/null
then
jot -w %i -r 1 $1 $(($2 + 1))
fi
if command -v shuf &> /dev/null
then
shuf -i $1-$2 -n 1
fi
}
# Get a random line of a file # Get a random line of a file
# Usage: $(getlineoffile <file>) # Usage: $(getlineoffile <file>)
getlineoffile () { getlineoffile () {
MAXLINE=$(sed -n '$=' "$1") MAXLINE=$(sed -n '$=' "$1")
LINE=$(shuf -i 1-$MAXLINE -n 1) LINE=$(genrandinrange 1 $MAXLINE)
echo $(sed "${LINE}q;d" "$1") echo $(sed "${LINE}q;d" "$1")
} }
@ -90,7 +103,7 @@ play_playlist () {
do do
PLFILE="$MIDIFYLOCAL/lists/$PLIST.mm3u" PLFILE="$MIDIFYLOCAL/lists/$PLIST.mm3u"
MAXLINE=$(sed -n '$=' "$PLFILE") MAXLINE=$(sed -n '$=' "$PLFILE")
LINE=$(shuf -i 1-$MAXLINE -n 1) LINE=$(genrandinrange 1 $MAXLINE)
MFILE=$(sed "${LINE}q;d" "$PLFILE") MFILE=$(sed "${LINE}q;d" "$PLFILE")
play_song $MIDIFYLOCAL/midi/$MFILE play_song $MIDIFYLOCAL/midi/$MFILE
sleep 1 sleep 1
@ -102,7 +115,7 @@ play_playlist () {
do do
PLFILE=$TEMP/playlist.mm3u PLFILE=$TEMP/playlist.mm3u
MAXLINE=$(sed -n '$=' "$PLFILE") MAXLINE=$(sed -n '$=' "$PLFILE")
LINE=$(shuf -i 1-$MAXLINE -n 1) LINE=$(genrandinrange 1 $MAXLINE)
MFILE=$(sed "${LINE}q;d" "$PLFILE") MFILE=$(sed "${LINE}q;d" "$PLFILE")
curl -q $MIDIFYSERVER/midi/$MFILE > $TEMP/$MFILE curl -q $MIDIFYSERVER/midi/$MFILE > $TEMP/$MFILE
play_song $TEMP/$MFILE play_song $TEMP/$MFILE
@ -119,8 +132,11 @@ play_song () {
timidity -A 50 "$1" >/dev/null timidity -A 50 "$1" >/dev/null
elif [ "$MIDIPLAYER" = "2" ] elif [ "$MIDIPLAYER" = "2" ]
then then
pioplemidi-cli "$1" -nl -fp -frb -s playmidi "$1"
elif [ "$MIDIPLAYER" = "3" ] elif [ "$MIDIPLAYER" = "3" ]
then
pioplemidi-cli "$1" -nl -fp -frb -s
elif [ "$MIDIPLAYER" = "4" ]
then then
$MIDIPROG "$1" $MIDIPROG "$1"
else else