aboutsummaryrefslogtreecommitdiffstats
path: root/modules/media/screen-recording/screen-recording.sh
blob: 336c32e3a533a53ef7b79bfadc67dd95e2a37eb9 (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
#!/usr/bin/env bash
OUT_DIR="$HOME/Videos/Recordings"
mkdir -p "$OUT_DIR"

# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'

# 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
		echo -e "${YELLOW}Select a window or draw a box...${NC}"
		GEOMETRY=$(slurp)

		if [ -z "$GEOMETRY" ]; then
			echo "Selection cancelled. Exiting."
			exit 1
		fi
	else
		echo -e "${RED}Error: 'slurp' not found.${NC} Recording full screen..."
		sleep 1
	fi
fi

# Start recording
FILENAME="$OUT_DIR/recording-$(date +%Y%m%d-%H%M%S).mp4"

echo -e "${GREEN}Recording started!${NC}"
echo -e "Press ${YELLOW}'q'${NC} in this terminal to stop."
echo "File: $FILENAME"
echo "------------------------------------------------"

if [ -n "$GEOMETRY" ]; then
	wf-recorder -g "$GEOMETRY" -f "$FILENAME"
else
	wf-recorder -f "$FILENAME"
fi

echo -e "\n${GREEN}Done!${NC} Video saved to $FILENAME"