summary refs log tree commit diff
path: root/bin/screenrec
blob: 5324ead16470cf7412e660a3be871b6333344cb7 (plain) (blame)
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
#!/bin/sh
set -eu

update_waybar() {
	sleep .5
	pkill -RTMIN+1 -x waybar
}

trap '{ update_waybar & disown; }' SIGCHLD EXIT

if [ "${1:-}" = "stop" ]; then
	exec pkill -HUP -x wl-screenrec
fi

screengrab_dir=$XDG_VIDEOS_DIR/screengrabs
screengrab_path=$screengrab_dir/"$(date --iso-8601=seconds).mkv"

mkdir -p $screengrab_dir || exit 1

output=$(slurp -b '#000000aa' -c '#4E437188' -w 50 -f '%o' -or)

update_waybar & disown

wl-screenrec --filename="$screengrab_path" --output="$output" $@ || true

wl-copy "$screengrab_path"

fyi -a screenrec "screenrec" "$screengrab_path"