-
Notifications
You must be signed in to change notification settings - Fork 0
/
byzanz-window
executable file
·51 lines (41 loc) · 1.01 KB
/
byzanz-window
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
#!/bin/bash
# Record a gif with byzanz.
# Prompts for window or screen region
# Stops with ctrl+c
IMAGE="$HOME/Desktop/screencast-$(date +'%F.%T').gif"
function window_dimensions() {
info="$(xwininfo)"
x=$(echo "$info" | grep 'Absolute upper-left X' | cut -f 7 -d' ')
y=$(echo "$info" | grep 'Absolute upper-left Y' | cut -f 7 -d' ')
w=$(echo "$info" | grep Width | cut -f 4 -d' ')
h=$(echo "$info" | grep Height | cut -f 4 -d' ')
echo "-x $x -w $w -y $y -h $h"
}
function spinner() {
spinner=(/ - \\ \| / - \\ \| )
pos=0
while :
do
printf "\b"${spinner[$pos]}
(( pos=(pos + 1)%8 ))
sleep 0.2
done
}
export -f spinner
function open_image() {
if [ -s $IMAGE ]
then
xdg-open $IMAGE
fi
exit
}
trap open_image INT
if ! which byzanz-record > /dev/null 2>&1;
then
echo "byzanz not found, please install first."
exit
fi
echo "Choose the window to record"
DIMS=$(window_dimensions)
echo "Recording window... ctrl+c to stop!"
byzanz-record $DIMS "$IMAGE" --exec "bash -c spinner"