From 0323869b0b7faa4214544cf339e096a5c0d16cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Mon, 14 Dec 2020 00:30:47 +0300 Subject: Improvements to swayrecord script Now if it detects more than one display, it asks for the display you wish to record. --- dotfiles/.local/bin/swayrecord | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'dotfiles/.local') diff --git a/dotfiles/.local/bin/swayrecord b/dotfiles/.local/bin/swayrecord index 23171e2..13b6e4d 100755 --- a/dotfiles/.local/bin/swayrecord +++ b/dotfiles/.local/bin/swayrecord @@ -10,6 +10,7 @@ if ! [ -d $AREC_DIR ]; then mkdir -p $AREC_DIR fi +DISPLAY="" OUTPUT="$(date '+%y%m%d-%H%M-%S')" TYPE="$1" VIDEO_PID="" @@ -69,7 +70,7 @@ killrecording () { } video () { - wf-recorder -f "$VREC_DIR/video-$OUTPUT.mp4" & + wf-recorder -o "$DISPLAY" -f "$VREC_DIR/video-$OUTPUT.mp4" & VIDEO_PID=$! echo $$ > ~/.cache/recordingpid echo "🔴" > ~/.cache/recordingicon @@ -83,7 +84,7 @@ screenshare () { loopbackcam="$(v4l2-ctl --list-devices | \ grep v4l2loopback -m1 -A1 | \ sed -e '1d' -e 's/\s//g')" - wf-recorder -x yuv420p -c rawvideo -m v4l2 -f $loopbackcam & + wf-recorder -o "$DISPLAY" -x yuv420p -c rawvideo -m v4l2 -f $loopbackcam & VIDEO_PID=$! echo $$ > ~/.cache/recordingpid echo "📺" > ~/.cache/recordingicon @@ -93,7 +94,7 @@ screenshare () { } screencast () { - wf-recorder -f "$VREC_DIR/temp-$OUTPUT.mp4" & + wf-recorder -o "$DISPLAY" -f "$VREC_DIR/temp-$OUTPUT.mp4" & VIDEO_PID=$! ffmpeg -f alsa -i default -c:a mp3 "$VREC_DIR/temp-$OUTPUT.mp3" & AUDIO_PID=$! @@ -130,6 +131,12 @@ if [ -f "$HOME/.cache/recordingpid" ]; then exit fi +if [ $(swaymsg -t get_outputs | jq '. | length') -gt 1 ]; then +DISPLAY=$(swaymsg -t get_outputs | grep -E "name" | sed "s/^.*\"name\": \"//g;s/\",$//g;" | bemenu -p "Select display for capture: " --tf="$BEMENU_TF" --tb="$BEMENU_NB" --fb="$BEMENU_NB" --fn="$BEMENU_FN" --nb="$BEMENU_NB" --nf="$BEMENU_NF" --hf="$BEMENU_HF" --hb="$BEMENU_HB" --monitor="$BEMENU_MONITOR") +else + DISPLAY="$(swaymsg -t get_outputs | jq '.[0][\"name\"]')" +fi + case $1 in video) video;; screencast) screencast;; -- cgit v1.2.3