From 7a4eba60cd404806079d6ebb7ac71f07ec43c7ac Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 3 May 2022 11:29:48 +0200 Subject: [PATCH] bin: little script corrections --- .config/yadm/unignore | 1 + .local/bin/scripts/bag | 2 +- .local/bin/scripts/focus | 2 +- .local/bin/scripts/mp | 9 +++++---- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.config/yadm/unignore b/.config/yadm/unignore index 3a057ee..f6348fe 100644 --- a/.config/yadm/unignore +++ b/.config/yadm/unignore @@ -2,6 +2,7 @@ $XDG_CONFIG_HOME/yadm $XDG_CONFIG_HOME/doom $XDG_CONFIG_HOME/git $XDG_CONFIG_HOME/nvim +$XDG_CONFIG_HOME/espanso $XDG_CONFIG_HOME/zsh/completion $CONFIG_SHELLS $HOME/.local/bin/scripts diff --git a/.local/bin/scripts/bag b/.local/bin/scripts/bag index 6660762..9849f28 100755 --- a/.local/bin/scripts/bag +++ b/.local/bin/scripts/bag @@ -18,4 +18,4 @@ ${run:-sudo --preserve-env=BORG_REPO BORG_PASSPHRASE="$($BORG_PASSCOMMAND)" borg $(echo $DIRS_IGNORE_SAFE -x 'software-challenge/**/build' -x state/emacs -x state/go -x .local/lib -x .cpan -x *cache | sed 's|-x \([^ ]\+\)|-e sh:**/\1|g') \ "$name" $(test $# -eq 0 && echo etc home root || test $# -eq 1 && echo $1) "${@:2}" 2>&1 -sudo chown -R $USER:$USER "$BORG_REPO" +test -n "$run" || sudo chown -R $USER:$USER "$BORG_REPO" diff --git a/.local/bin/scripts/focus b/.local/bin/scripts/focus index 4b58253..3e56235 100755 --- a/.local/bin/scripts/focus +++ b/.local/bin/scripts/focus @@ -9,7 +9,7 @@ then mp -q "$PLAYLISTS/focus.m3u" else (find -L $PLAYLISTS -iname "focus-$1.m3u" -print0 | grep --null-data . || find -L $PLAYLISTS -iname "$1.m3u*" -print0 | grep --null-data . || - find -L $MUSIC $(echo "$@" | sed 's/\w\+/-iname *\0*/g') -prune -exec find {} -size +1M -type f -not -iregex ".*.\(jpe?g\|png\)" -print0 \; ) | + find -L $MUSIC $(echo "$@" | sed 's/\w\+/-iname *\0* /g') -prune -exec find {} -size +1M -type f -not -iregex ".*.\(jpe?g\|png\)" -print0 \; ) | xargs -0 mp -q fi if test $(mpc playlist | wc -l) -gt 1; then diff --git a/.local/bin/scripts/mp b/.local/bin/scripts/mp index 70cdfab..c172ed2 100755 --- a/.local/bin/scripts/mp +++ b/.local/bin/scripts/mp @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # [M]edia [P]lay # Play given files on mpd, playing external files through symlinking and recursively resolving playlists # depends: xargs realpath mpc @@ -11,9 +11,10 @@ then shift test "$1" = "-v" && verbose=-v && set -x && shift # TODO this is sooo slow... for arg - do filepath="$({ find "$(dirname -- "$arg")" -maxdepth 1 -name "$(basename -- "$arg")*" -exec realpath {} + || - find "$MUSIC/$(dirname -- "$arg")" "$MUSIC/Playlists/$(dirname -- "$arg")" -maxdepth 1 \ - -name "$(basename -- "$arg")*" -exec realpath {} +; } 2>/dev/null)" + do + filepath="$({ find "$(dirname -- "$arg")" -maxdepth 1 -name "$(basename -- "$arg")*" -exec realpath {} + || + find "$MUSIC/$(dirname -- "$arg")" "$MUSIC/Playlists/$(dirname -- "$arg")" -maxdepth 1 \ + -name "$(basename -- "$arg")*" -exec realpath {} +; } 2>/dev/null)" test -n "$verbose" && echo "Scanning path '$filepath' $( test "$arg" != "$filepath" && echo "from '$arg' ")(MUSIC: '$MUSIC', PWD: '$PWD')" >&2 test $(printf "$filepath" | wc -l) -gt 0 && printf "$filepath" | xargs --delim='\n' "$0" -r $verbose && continue