-
Notifications
You must be signed in to change notification settings - Fork 16
/
record_screen.sh
executable file
·80 lines (69 loc) · 1.48 KB
/
record_screen.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
trap ctrl_c INT QUIT TERM
function ctrl_c() {
xdotool key 'Super+Ctrl+f';
snore 2
xdotool key 'Super+Ctrl+q';
snore 2
kill -2 $pid
exit
}
function snore()
{
local IFS
[[ -n "${_snore_fd:-}" ]] || exec {_snore_fd}<> <(:)
read ${1:+-t "$1"} -u $_snore_fd || :
}
function help()
{
echo "Usage:"
echo "-d <dir> save directory"
echo "-p <prefix> prefix"
echo "-s <second> sleep for a second before start recording (default 10)"
}
save_dir=./
prefix=cabot_screen_recording
delay=10
pid=
pwd=`pwd`
scriptdir=`dirname $0`
cd $scriptdir
scriptdir=`pwd`
while getopts "hd:p:s:" arg; do
case $arg in
h)
help
exit
;;
d)
save_dir=$OPTARG
;;
p)
prefix=$OPTARG
;;
s)
delay=$OPTARG
;;
esac
done
shift $((OPTIND-1))
save_dir=$(realpath $save_dir)
echo "saving file to $save_dir/$prefix"
KAZAM_CONF_FILE=~/.config/kazam/kazam.conf
mv $KAZAM_CONF_FILE ${KAZAM_CONF_FILE}.back
cp $scriptdir/tools/config/kazam.conf $KAZAM_CONF_FILE
sed -i "s'autosave_video = .*'autosave_video = True'" $KAZAM_CONF_FILE
sed -i "s'autosave_video_dir = .*'autosave_video_dir = ${save_dir}'" $KAZAM_CONF_FILE
sed -i "s'autosave_video_file = .*'autosave_video_file = ${prefix}'" $KAZAM_CONF_FILE
cat $KAZAM_CONF_FILE
pushd $save_dir
kazam &
pid=$!
echo "wait $delay"
snore $delay
xdotool key 'Super+Ctrl+r';
popd
while [ 1 -eq 1 ];
do
snore 1
done