/
record
executable file
·49 lines (45 loc) · 1.05 KB
/
record
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
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
#
# Handles recording of system audio.
#
# $1 - The function to perform. Possible values:
# start - Starts recording.
# stop - Stops recording.
# $2 - The name to append to the recording. Possibly a username. Only required
# for stopping.
#
# Examples:
#
# record start
# record stop github-dj-holman
if test "$1" = "start"
then
osascript << APPLESCRIPT
tell application "QuickTime Player"
activate
set recording to new audio recording
start recording
end tell
APPLESCRIPT
else
osascript << APPLESCRIPT
tell application "QuickTime Player"
activate
stop document 1
end tell
APPLESCRIPT
# Sleep so QuickTime doesn't get confused
sleep 5
# Import recording
filename="$2-$(date +%Y-%m-%d_%H%M%S)"
mv "$HOME/Movies/Audio Recording.m4a" "$HOME/Movies/$filename.m4a"
script/add-to-itunes "$HOME/Movies/$filename.m4a"
rm -rf "$HOME/Movies/$filename.m4a"
# Close out
osascript << APPLESCRIPT
tell application "QuickTime Player"
activate
close document 1
end tell
APPLESCRIPT
fi