@@ -10,7 +10,7 @@ GUIPLAYER="${GUIPLAYER}" | |||||
NUMTRACKS="${NUMTRACKS:-100}" | NUMTRACKS="${NUMTRACKS:-100}" | ||||
if [ ! -z "$GUIPLAYER" ]; then | if [ ! -z "$GUIPLAYER" ]; then | ||||
find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n "$NUMTRACKS" | xargs -d "\n" "$GUIPLAYER" > /dev/null 2>&1 & | find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf -n "$NUMTRACKS" | xargs -d "\n" "$GUIPLAYER" > /dev/null 2>&1 & | ||||
# detach the player | # detach the player | ||||
sleep 1 | sleep 1 | ||||
@@ -26,7 +26,7 @@ elif which mocp >/dev/null 2>&1; then | |||||
state=$(mocp -i | grep "State:" | cut -d' ' -f2) | state=$(mocp -i | grep "State:" | cut -d' ' -f2) | ||||
if [ "$state" = 'PLAY' ]; then | if [ "$state" = 'PLAY' ]; then | ||||
# add up to 100 random audio files | # add up to 100 random audio files | ||||
find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n "$NUMTRACKS" | xargs -d "\n" mocp -a | find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf -n "$NUMTRACKS" | xargs -d "\n" mocp -a | ||||
exit | exit | ||||
fi | fi | ||||
fi | fi | ||||
@@ -35,7 +35,7 @@ elif which mocp >/dev/null 2>&1; then | |||||
mocp -c | mocp -c | ||||
# add up to 100 random audio files | # add up to 100 random audio files | ||||
find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n "$NUMTRACKS" | xargs -d "\n" mocp -a | find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf -n "$NUMTRACKS" | xargs -d "\n" mocp -a | ||||
# start playing | # start playing | ||||
mocp -p | mocp -p | ||||
@@ -4,14 +4,18 @@ | |||||
# Opens in $VISUAL or $EDITOR if text | # Opens in $VISUAL or $EDITOR if text | ||||
# Opens other type of files with xdg-open | # Opens other type of files with xdg-open | ||||
# | # | ||||
# Requires: fzf/fzy, xdg-open | # Requires: fd/find, fzf/fzy/skim, xdg-open | ||||
# | # | ||||
# Shell: POSIX compliant | # Shell: POSIX compliant | ||||
# Author: Arun Prakash Jana | # Author: Arun Prakash Jana | ||||
if which fzf >/dev/null 2>&1; then | if which fzf >/dev/null 2>&1; then | ||||
cmd="$FZF_DEFAULT_COMMAND" | cmd="$FZF_DEFAULT_COMMAND" | ||||
[ -z "$cmd" ] && cmd="find . -type f 2>/dev/null" | if which fd >/dev/null 2>&1; then | ||||
[ -z "$cmd" ] && cmd="fd -t f 2>/dev/null" | |||||
else | |||||
[ -z "$cmd" ] && cmd="find . -type f 2>/dev/null" | |||||
fi | |||||
entry="$(eval "$cmd" | fzf --delimiter / --nth=-1 --tiebreak=begin --info=hidden)" | entry="$(eval "$cmd" | fzf --delimiter / --nth=-1 --tiebreak=begin --info=hidden)" | ||||
# To show only the file name | # To show only the file name | ||||
# entry=$(find . -type f 2>/dev/null | fzf --delimiter / --with-nth=-1 --tiebreak=begin --info=hidden) | # entry=$(find . -type f 2>/dev/null | fzf --delimiter / --with-nth=-1 --tiebreak=begin --info=hidden) | ||||
@@ -7,6 +7,7 @@ | |||||
# - appends tracks and exits is MOC is running, else clears playlist and adds tracks | # - appends tracks and exits is MOC is running, else clears playlist and adds tracks | ||||
# - to randomize the order of files appended to the playlist, set SHUFFLE=1 | # - to randomize the order of files appended to the playlist, set SHUFFLE=1 | ||||
# if you add a directory with many files when SHUFFLE=1 is set, it might take a very long time to finish! | # if you add a directory with many files when SHUFFLE=1 is set, it might take a very long time to finish! | ||||
# - max 100 files are added | |||||
# | # | ||||
# Shell: POSIX compliant | # Shell: POSIX compliant | ||||
# Author: Arun Prakash Jana, ath3 | # Author: Arun Prakash Jana, ath3 | ||||
@@ -30,20 +31,13 @@ mocp_add () | |||||
for entry in $arr | for entry in $arr | ||||
do | do | ||||
if [ -d "$entry" ]; then | if [ -d "$entry" ]; then | ||||
arr2=$arr2$(find "$entry" -type f) | arr2=$arr2$(find "$entry" -type f \( ! -iname "*.m3u" ! -iname "*.pls" \)) | ||||
else | elif echo "$entry" | grep -qv '\.m3u$\|\.pls$' ; then | ||||
arr2=$(printf "%s\n%s" "$entry" "$arr2") | arr2=$(printf "%s\n%s" "$entry" "$arr2") | ||||
fi | fi | ||||
done | done | ||||
arr2=$(echo "$arr2" | awk 'BEGIN{srand();}{print rand()"\t"$0}' | sort -k1 -n | cut -f2-) | echo "$arr2" | shuf -n 100 | xargs -d "\n" mocp -a | ||||
for entry in $arr2 | |||||
do | |||||
if [ -f "$entry" ] && echo "$entry" | grep -qv '\.m3u$\|\.pls$' ; then | |||||
mocp -a "$entry" | |||||
fi | |||||
done | |||||
else | else | ||||
if [ "$resp" = "y" ]; then | if [ "$resp" = "y" ]; then | ||||
xargs < "$selection" -0 mocp -a | xargs < "$selection" -0 mocp -a | ||||