blob: 1afa2397de902d3bafd087550e7e4599c6638e96 (
plain)
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
|
#!/usr/bin/env bash
# Record the screen with wf-recorder into ~/Videos/Recordings,
# optionally selecting a region to capture with slurp.
OUT_DIR="$HOME/Videos/Recordings"
mkdir -p "$OUT_DIR"
info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
error() { printf '\033[1;31m==> error:\033[0m %s\n' "$*" >&2; }
die() {
error "$*"
exit 1
}
# Argument parsing
SELECT_MODE=false
while [[ $# -gt 0 ]]; do
case $1 in
-s | --select) SELECT_MODE=true ;;
esac
shift
done
# Geometry selection
GEOMETRY=""
if [ "$SELECT_MODE" = true ]; then
if command -v slurp >/dev/null 2>&1; then
info "Select a window or draw a box..."
GEOMETRY=$(slurp)
if [ -z "$GEOMETRY" ]; then
info "Selection cancelled. Exiting."
exit 1
fi
else
warn "slurp not found. Recording full screen..."
sleep 1
fi
fi
# Start recording
FILENAME="$OUT_DIR/recording-$(date +%Y%m%d-%H%M%S).mp4"
info "Recording started!"
echo " Press 'q' in this terminal to stop."
echo " File: $FILENAME"
if [ -n "$GEOMETRY" ]; then
wf-recorder -g "$GEOMETRY" -f "$FILENAME"
else
wf-recorder -f "$FILENAME"
fi
info "Done! Video saved to $FILENAME"
|