dotfiles

<-- duh.
Log | Files | Refs | LICENSE

commit eeed2ae3c17263184de484fd571a5fdb6e92c248
parent b42db1a90d08a622e4a0b3e3398db5cfc6e3baef
Author: hhvn <hayden@haydenvh.com>
Date:   Sat,  6 Feb 2021 12:28:25 +0000

.config/sxhkd/sxhkdrc .scripts/bin/rmpv: speed up music shuffling in large dirs by using a filelist

Diffstat:
M.config/sxhkd/sxhkdrc | 2+-
M.scripts/bin/rmpv | 10+++++++---
2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc @@ -104,7 +104,7 @@ super + ctrl + u dmpv general/music/ /tmp/mpv-socket /tmp/mpv-socket2 --no-video super + alt + {y,u} - rmpv general/{videos,music}/ 150 + rmpv general/{videos,music}/list 150 super + ctrl + {i,p} hmpv {back,forward} /tmp/mpv-socket diff --git a/.scripts/bin/rmpv b/.scripts/bin/rmpv @@ -4,15 +4,19 @@ # Created by Hayden Hamilton # # hayden@haydenvh.com -# Copyright (c) 2019-2020 Hayden Hamilton. +# Copyright (c) 2019-2021 Hayden Hamilton. -files=$(find "$1" -type f | grep -E 'mp3$|opus$|mkv$|mp4$|flac$|m4a$|webm$|wav$' | shuf | head -n $2) +[ -z "$1" ] || [ ! -z "$3" ] && echo "usage: rmpv <directory|filelist> [size]" + +[ -f "$1" ] && files=$(grep -E "mp3 |opus |mkv |mp4 |flac |m4a |webm |wav " < "$1" | \ + awk -F" " '{for (i=0; i < $2; i++) print $1}' | shuf | head -n ${2:-50} | sed "s~^.~$(dirname $1)~") +[ -d "$1" ] && files=$(find "$1" -type f | grep -E 'mp3$|opus$|mkv$|mp4$|flac$|m4a$|webm$|wav$' | shuf | head -n ${2:-50}) echo "$files" | grep '[[:alnum:]]' >/dev/null || { echo "No files found..." exit 1 } -echo "$1" | grep "music" && { +echo "$1" | grep "music" >/dev/null && { echo "$files" | tr '\n' '\0' | xargs -0 mpv --input-ipc-server=/tmp/mpv-socket --no-video -- } || { echo "$files" | tr '\n' '\0' | xargs -0 mpv --input-ipc-server=/tmp/mpv-socket $files