diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2020-12-14 00:30:47 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2020-12-14 00:30:47 +0300 |
commit | 0323869b0b7faa4214544cf339e096a5c0d16cb6 (patch) | |
tree | 3c2239092de40eb06af0068202183be62ee4c978 | |
parent | d74a5a26385ebb21903da26e3d239a4929c4a5b7 (diff) | |
download | swayrice-0323869b0b7faa4214544cf339e096a5c0d16cb6.tar.gz swayrice-0323869b0b7faa4214544cf339e096a5c0d16cb6.zip |
Improvements to swayrecord script
Now if it detects more than one display, it asks for the display you
wish to record.
-rwxr-xr-x | dotfiles/.local/bin/swayrecord | 13 |
1 files changed, 10 insertions, 3 deletions
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;; |