From 32ccac91849aeb48c63809ef0fd6d087fd487762 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Wed, 17 Nov 2021 15:56:16 +0100 Subject: [PATCH] bin: fix oversights & improve freq --- .local/bin/scripts/clean | 5 ++--- .local/bin/scripts/freq | 25 ++++++++++++++++++++----- .local/bin/scripts/rd | 2 +- .local/bin/scripts/sd | 21 ++++++++++++--------- 4 files changed, 35 insertions(+), 18 deletions(-) diff --git a/.local/bin/scripts/clean b/.local/bin/scripts/clean index b2c27e4..0f0e0c9 100755 --- a/.local/bin/scripts/clean +++ b/.local/bin/scripts/clean @@ -44,9 +44,8 @@ fi highlight "d to recursively remove development caches" if [[ $1 =~ "d" ]]; then - rm -rf .npm .yarn - arg-test -name "src" -prune -o \ - -type d \( -name 'cache' $(echo $DIRS_GENERATED | sed 's|-x \([^ ]\+\)|-o -name "\1"|g') \ + find -name "src" -prune -o \ + -type d \( -name 'cache' $(echo $DIRS_GENERATED | sed 's|-x \([^ ]\+\)|-o -name \1|g') \) \ -print -exec rm -r {} + -prune echo -n " " && highlight "build directories" find $DATA/2-standards/dev/aur -mindepth 2 -maxdepth 2 -type d -not -name ".*" \ diff --git a/.local/bin/scripts/freq b/.local/bin/scripts/freq index 672ea96..1fdfdc3 100755 --- a/.local/bin/scripts/freq +++ b/.local/bin/scripts/freq @@ -1,6 +1,21 @@ #!/bin/sh -# Show a frequance spectrogram using sox and timg -out=${2:-/tmp/$1-sox.png} -mkdir -p "$(dirname "$out")" -sox "$1" -n spectrogram -o "$out" -timg --title "$out" +# Show a frequence spectrogram using sox and timg +# https://sound.stackexchange.com/questions/40226/show-the-differences-between-two-similar-audio-files-using-graphical-method +case $1 in + (-a) shift + for arg; do $0 "$arg"; done + ;; + (-d) shift + diff="/tmp/diff-$1-$2.wav" + ffmpeg -y -v warning -i "$1" "/tmp/$1.wav" + ffmpeg -y -v warning -i "$2" "/tmp/$2.wav" + sox -m -v 1 "/tmp/$1.wav" -v -1 "/tmp/$2.wav" "$diff" + $0 "$diff" + ;; + (*) + out="${2:-/tmp/freq-$(basename "$1").png}" + mkdir -p "$(dirname "$out")" + sox "$1" -n spectrogram -o "$out" + timg --title "$out" + ;; +esac diff --git a/.local/bin/scripts/rd b/.local/bin/scripts/rd index 317d57c..cd3edf1 100755 --- a/.local/bin/scripts/rd +++ b/.local/bin/scripts/rd @@ -6,7 +6,7 @@ do test -w "$f" && elevate="" || elevate=sudo if test -d "$f"; then if test -e "$f/.git" || test -e "$f/packed-refs" - then echo -n "Force delete git project $f?" + then echo -n "Force delete git project $f? " read answer test "$answer" = "y" && $elevate rm -rf "$f" else find "$f" -maxdepth 4 -type d -empty -printf "Removing empty %p\n" -delete diff --git a/.local/bin/scripts/sd b/.local/bin/scripts/sd index 4e85940..e12a9fe 100755 --- a/.local/bin/scripts/sd +++ b/.local/bin/scripts/sd @@ -1,11 +1,14 @@ #!/bin/sh # disk size usage information -IFS="\n" -cols=$(tput cols) -lsblk --output name,size,fsuse%,mountpoints,label$(test $cols -gt 110 && echo ',uuid,fstype') --width $cols | - while read line - do p=$(echo "$line" | sed 's|.* \([[:digit:]]\+\)%.*|\1|;t;c0') - printf "$(expr "$line" : " " >/dev/null || echo "\033[$(test -z "$first" && echo "4" || expr "5;31" \& "$p" \> 98 \| "31" \& "$p" \> 97 \| "33" \& "$p" \> 94 \| "35" \& "$p" \> 90)m")%s\n" "$line" - first=1 - done -# df -B1M -x tmpfs -x devtmpfs -x squashfs | awk -v a="\033[31m" -v b="\033[33m" -v c="\033[35m" -v n="\033[0m" 'NR==1 {printf "%-20s %6s %7s %9s %s\n",$1,$5,$3,$4,$6} NR>1 {u=strtonum($5); printf (u > 99) ? a : (u > 97) ? b : (u > 94) ? c : ""; printf "%-20s %6s %6.1fG %8.1fG %s\n",$1,$5,$3/1000,$4/1000,$6; printf n}' +if test "$1" = "f" + then df -B1M -x tmpfs -x devtmpfs -x squashfs | awk -v a="\033[31m" -v b="\033[33m" -v c="\033[35m" -v n="\033[0m" 'NR==1 {printf "%-20s %6s %7s %9s %s\n",$1,$5,$3,$4,$6} NR>1 {u=strtonum($5); printf (u > 99) ? a : (u > 97) ? b : (u > 94) ? c : ""; printf "%-20s %6s %6.1fG %8.1fG %s\n",$1,$5,$3/1000,$4/1000,$6; printf n}' + else + IFS="\n" + cols=$(tput cols) + lsblk --output name,size,fsuse%,mountpoints,label$(test $cols -gt 110 && echo ',uuid,fstype') --width $cols | + while read line + do p=$(echo "$line" | sed 's|.* \([[:digit:]]\+\)%.*|\1|;t;c0') + printf "$(expr "$line" : " " >/dev/null || echo "\033[$(test -z "$first" && echo "4" || expr "5;31" \& "$p" \> 98 \| "31" \& "$p" \> 97 \| "33" \& "$p" \> 94 \| "35" \& "$p" \> 90)m")%s\n" "$line" + first=1 + done +fi