Add sxmo_record.sh script and Record entry to scripts menu

master
Miles Alan 5 years ago
parent 29098d750b
commit d5ca81b991
  1. 69
      scripts/appscripts/sxmo_record.sh
  2. 1
      scripts/core/sxmo_appmenu.sh

@ -0,0 +1,69 @@
#!/usr/bin/env sh
RECDIR=~/Recordings
OLDAUDIOF="$(mktemp)"
alsactl --file "$OLDAUDIOF" store
mkdir -p "$RECDIR"
restoreaudio() {
alsactl --file "$OLDAUDIOF" restore
}
record() {
TEMPFILE="$(mktemp --suffix=.wav)"
NOW="$(date '+%y%m%d_%H%M%S')"
st -e arecord -vv -f cd -c 1 "$TEMPFILE"
DUR="$(
mediainfo "$TEMPFILE" |
grep ^Duration |
head -n1 |
cut -d: -f2 |
tr -d " "
)"
FILENAME="${NOW}_${DUR}.wav"
FILE="${RECDIR}/${FILENAME}"
mv "$TEMPFILE" "$FILE"
while true; do
PICK="$(
printf %b "
Save: $FILENAME
Playback: ($DUR)\n
Delete Recording
" |
xargs -0 echo | sed '/^[[:space:]]*$/d' | awk '{$1=$1};1' |
dmenu -p "$DUR" -fn Terminus-18 -c -l 10
)"
if echo "$PICK" | grep "Playback"; then
restoreaudio
st -e mpv -v "$FILE"
elif echo "$PICK" | grep "Delete Recording"; then
rm "$FILE"
echo "File deleted." | dmenu -fn Terminus-18 -c -l 10
return
else
return
fi
done
}
while true; do
NRECORDINGS="$(ls -1 "$RECDIR" | wc -l)"
OPTION="$(
printf %b "Line Jack\nMicrophone\n($NRECORDINGS) Recordings\nClose Menu" |
dmenu -fn Terminus-30 -c -p "Record" -l 20
)"
if [ "$OPTION" = "Line Jack" ]; then
sxmo_megiaudioroute -l
record
elif [ "$OPTION" = "Microphone" ]; then
sxmo_megiaudioroute -m
record
elif echo "$OPTION" | grep "Recordings$"; then
restoreaudio
sxmo_files.sh "$RECDIR"
elif [ "$OPTION" = "Close Menu" ]; then
restoreaudio
exit 0
fi
done

@ -35,6 +35,7 @@ programchoicesinit() {
echo $WMCLASS | grep -i "scripts" && CHOICES="$(echo "
Web Search ^ 0 ^ sxmo_websearch.sh
Files ^ 0 ^ sxmo_files.sh
Record ^ 0 ^ sxmo_record.sh
Timer ^ 0 ^ sxmo_timer.sh
Youtube ^ 0 ^ sxmo_youtube.sh video
Youtube (Audio) ^ 0 ^ sxmo_youtube.sh audio

Loading…
Cancel
Save