forked from SergKolo/sergrep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio_record.sh
executable file
·38 lines (32 loc) · 887 Bytes
/
audio_record.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Author: Serg Kolo
# Date: Dec 1, 2016
# Purpose: simple script for recording audio with arecord
# Written for: http://askubuntu.com/q/855893/295286
record_audio()
{
# Set up some variables to control arecord here
# Please remember to quote the variables
# and pay attention to slashes in file paths
filetype="wav"
filename="record_$(date +%H_%M_%m_%d_%Y)"
directory="$HOME/Music/recordings/"
if ! [ -d "$directory" ];
then
mkdir "$directory"
fi
# This part will initiate recording of timestamped
# please see arecord's man page for other options
notify-send "Recording started"
exec arecord -t "$filetype" "$directory""$filename"."$filetype"
}
main()
{
if pgrep -f "arecord" ;
then
pkill -f "arecord" && notify-send "Recording stopped"
else
record_audio
fi
}
main "$@"