From 92376471ab255fa21a70a02cb16e2436c8bd058e Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Mon, 20 Sep 2021 09:22:23 +1200 Subject: [PATCH 1/1] Use filename instead of UUID for sink name --- pulserecorder | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) 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 …" -- 2.39.5