]> Sergey Matveev's repositories - nnn.git/commitdiff
Various plugin improvements
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 26 Apr 2020 18:35:11 +0000 (00:05 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 26 Apr 2020 18:35:40 +0000 (00:05 +0530)
plugins/boom
plugins/fzopen
plugins/mocplay

index 14f481da7d543d315229e66b8de96357f39a5a41..aa7763471c5fd2f7e18ccc54758771a9eb7d13ac 100755 (executable)
@@ -10,7 +10,7 @@ GUIPLAYER="${GUIPLAYER}"
 NUMTRACKS="${NUMTRACKS:-100}"
 
 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
     sleep 1
@@ -26,7 +26,7 @@ elif which mocp >/dev/null 2>&1; then
         state=$(mocp -i | grep "State:" | cut -d' ' -f2)
         if [ "$state" = 'PLAY' ]; then
             # 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
         fi
     fi
@@ -35,7 +35,7 @@ elif which mocp >/dev/null 2>&1; then
     mocp -c
 
     # 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
     mocp -p
index 9f5ff052f15ba48bc22e56c98c95ccacb1d1d3b0..e262d684e323288bc97ef55850cce71cb70c7c55 100755 (executable)
@@ -4,14 +4,18 @@
 #              Opens in $VISUAL or $EDITOR if text
 #              Opens other type of files with xdg-open
 #
-# Requires: fzf/fzy, xdg-open
+# Requires: fd/find, fzf/fzy/skim, xdg-open
 #
 # Shell: POSIX compliant
 # Author: Arun Prakash Jana
 
 if which fzf >/dev/null 2>&1; then
     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)"
     # To show only the file name
     # entry=$(find . -type f 2>/dev/null | fzf --delimiter / --with-nth=-1 --tiebreak=begin --info=hidden)
index 5db44b94c5f4432e4f739112f279552413134fbd..36e7e500050da2db85c2967d7ac2ba2cc27fc239 100755 (executable)
@@ -7,6 +7,7 @@
 # - 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
 #   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
 # Author: Arun Prakash Jana, ath3
@@ -30,20 +31,13 @@ mocp_add ()
         for entry in $arr
         do
             if [ -d "$entry" ]; then
-                arr2=$arr2$(find "$entry" -type f)
-            else
+                arr2=$arr2$(find "$entry" -type f \( ! -iname "*.m3u" ! -iname "*.pls" \))
+            elif echo "$entry" | grep -qv '\.m3u$\|\.pls$' ; then
                 arr2=$(printf "%s\n%s" "$entry" "$arr2")
             fi
         done
 
-        arr2=$(echo "$arr2" | awk 'BEGIN{srand();}{print rand()"\t"$0}' | sort -k1 -n | cut -f2-)
-        for entry in $arr2
-        do
-            if [ -f "$entry" ] &&  echo "$entry" | grep -qv '\.m3u$\|\.pls$' ; then
-                mocp -a "$entry"
-            fi
-        done
-
+        echo "$arr2" | shuf -n 100 | xargs -d "\n" mocp -a
     else
         if [ "$resp" = "y" ]; then
             xargs < "$selection" -0 mocp -a