-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathscreenshare.sh
More file actions
executable file
·41 lines (38 loc) · 1.47 KB
/
screenshare.sh
File metadata and controls
executable file
·41 lines (38 loc) · 1.47 KB
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
#!/usr/bin/env bash
## Starts, stops and shows status for screensharing
geometry() {
windowGeometries=$(
# `height - 1` is there because of: https://github.com/ammen99/wf-recorder/pull/56 (I could remove it if it's merged, maybe)
swaymsg -t get_workspaces -r | jq -r '.[] | select(.focused) | .rect | "\(.x),\(.y) \(.width)x\(.height - 1)"'
swaymsg -t get_outputs -r | jq -r '.[] | select(.active) | .rect | "\(.x),\(.y) \(.width)x\(.height)"'
)
geometry=$(slurp -b "#45858820" -c "#45858880" -w 3 -d <<<"$windowGeometries") || exit $?
echo "$geometry"
}
{
if [ "$1" == "stop" ]; then
if pgrep ffplay >/dev/null; then
pkill ffplay >/dev/null
fi
if pgrep wf-recorder >/dev/null; then
pkill wf-recorder >/dev/null
fi
notify-send -t 2000 "Wayland recording has been stopped"
elif [ "$1" == "is-recording" ]; then
if pgrep wf-recorder >/dev/null; then
notify-send -t 2000 "Wayland recording is up"
else
notify-send -t 2000 "No Wayland recording"
fi
else
if ! pgrep wf-recorder >/dev/null; then
geometry=$(geometry) || exit $?
unset SDL_VIDEODRIVER
wf-recorder -c rawvideo -x yuv420p -m avi -f >(ffplay -window_title Screenshare -f avi -) --geometry="$geometry" &
sleep 0.5
# a hack so FPS is not dropping
swaymsg [title=Screenshare] floating enable, move position 1800 900
fi
notify-send -t 2000 "Wayland recording has been started"
fi
} >~/.wayland-share-screen.log 2>&1