From: martin f. krafft Date: Sun, 19 Sep 2021 21:22:23 +0000 (+1200) Subject: Use filename instead of UUID for sink name X-Git-Url: https://git.madduck.net/code/pulserecorder.git/commitdiff_plain/92376471ab255fa21a70a02cb16e2436c8bd058e?hp=0419e8fbc114f36a087acd8ea6de65cbfcfec788 Use filename instead of UUID for sink name --- diff --git a/pulserecorder b/pulserecorder index 211c6d5..7d3860e 100755 --- a/pulserecorder +++ b/pulserecorder @@ -91,6 +91,28 @@ pa_get_next_index() { } } +uuidgen() { + hascmd() { command -v "$@" >/dev/null;} + if hascmd uuid; then uuid + elif hascmd uuidgen; then uuidgen + elif hascmd python3; then + python3 -c 'import uuid; print(uuid.uuid1())' + elif hascmd python; then + python -c 'import uuid; print(uuid.uuid1())' + else + dd if=/dev/urandom bs=16 count=1 status=none | base64 + fi +} + +if [ -z "$outfile" ]; then + uuid=$(uuidgen) + outfile="${uuid}.ogg" +fi + +if [ -f "$outfile" ] && [ $clobber -eq 0 ]; then + echo >&2 "E: file exists, and -f not given: $outfile" + exit 1 +fi case "$index" in (last) @@ -117,29 +139,7 @@ if [ -z "$index" ]; then exit 1 fi -uuidgen() { - hascmd() { command -v "$@" >/dev/null;} - if hascmd uuid; then uuid - elif hascmd uuidgen; then uuidgen - elif hascmd python3; then - python3 -c 'import uuid; print(uuid.uuid1())' - elif hascmd python; then - python -c 'import uuid; print(uuid.uuid1())' - else - dd if=/dev/urandom bs=16 count=1 status=none | base64 - fi -} - -uuid=$(uuidgen) - -[ -n "$outfile" ] || outfile="${uuid}.ogg" - -if [ -f "$outfile" ] && [ $clobber -eq 0 ]; then - echo >&2 "E: file exists, and -f not given: $outfile" - exit 1 -fi - -devname="record-to-file-${uuid}" +devname="record-to-file-$(echo -n ${outfile%.*} | tr -c '[:alnum:]' '_')" echo >&2 "Recording source $index to $outfile …"