dgy
/
hexagons
Archived
1
0
Fork 0
This repository has been archived on 2021-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
hexagons/.local/bin/grabar

81 lines
2.1 KiB
Bash
Executable File

#!/bin/sh
# Blaze - record screen and audio
# https://github.com/cherrry9/blaze/
# modificado por deadguy
output="$HOME/vid/Screen/$(date '+%y%m%d-%H%M-%S').mp4"
m() { ${DMENU:-dmenu} "$@"; }
method="$(printf "Pantalla\nSelección" | m -w 200 -p "Grabar")"
if [ "$method" = "Pantalla" ]; then
# get information about the display
monitors="$(xrandr --listmonitors | awk 'NR>1 { printf $NF"\n" }')"
# if there's only one display, use that and skip asking
if [ "$(printf "%b\n" "$monitors" | wc -l)" = 1 ]; then
display="$monitors"
else # if there are other displays ask the user which one to use
[ ! "$display" ] && display="$(printf "%b" "$monitors" | m -w 200 -p "Pantalla")"
fi
set -- $(xrandr -q | grep "$display" | grep -oP '\d*x\d*\+\d*\+\d*' | tr '+x' ' ')
width="$1"
height="$2"
offX="$3"
offY="$4"
sonido="$(printf "Sí\nNo" | m -w 200 -p "Audio")"
if [ "$sonido" = "Sí" ]; then
# find default audio device
pacmd="$(pacmd list-sources | grep -i -B 1 output)"
dev="$(echo "$pacmd" | grep -i '\* index' ||
echo "$pacmd" | grep -i 'index' | head -n 1)"
audio="-f pulse -i $(echo "$dev" | grep -o '[0-9]')"
else
audio=""
fi
elif [ "$method" = "Selección" ]; then
# select an area and make each number a separate word
set -- $(slop -f '%w %h %x %y')
# get information about the display
width="$1"
height="$2"
offX="$3"
offY="$4"
[ "$((width % 2))" = 1 ] && width="$((width + 1))"
[ "$((height % 2))" = 1 ] && height="$((height + 1))"
else
printf "Método inválido.\n"
exit 1
fi
# ask the user if they want to start the recording
[ ! "$ready" ] && ready="$(printf "Sí\nNo" | m -w 200 -p "Empezar")"
[ "$ready" = "Sí" ] && {
notify-send -t 1500 "Grabando"
ffmpeg \
-loglevel error \
-y \
-thread_queue_size 4096 \
$audio \
-f x11grab \
-draw_mouse 1 \
-s "${width}x$height" \
-r 60 \
-i "$DISPLAY.0+$offX,$offY" \
-pix_fmt yuv420p \
-q:v 0 \
"$output" &
echo $! >/tmp/blaze-pid
}