#!/bin/sh # Blaze - record screen and audio # https://github.com/cherrry9/blaze/ # modificado por deadguy ICON_NO="$XDG_DATA_HOME/icons/Haiku/scalable/actions/process-stop.svg" ICON_RECORD="$XDG_DATA_HOME/icons/Haiku/scalable/devices/gnome-dev-camera.svg" output="$HOME/vid/Screen/$(date '+%F_%H_%M').mp4" fps=60 m() { rofi -dmenu -i -no-custom "$@"; } method="$(printf "Pantalla\nSelección" | m -p " ")" 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 -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 -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 gif="$(printf "Sí\nNo" | m -p "Gif")" if [ "$gif" = "Sí" ]; then output="$HOME/vid/Screen/$(date '+%F_%H_%M').gif" fps=15 fi # 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 notify-send -t 3000 -u critical -i "$ICON_NO" "Método inválido" exit 1 fi # ask the user if they want to start the recording [ ! "$ready" ] && ready="$(printf "Sí\nNo" | m -p "Empezar")" [ "$ready" = "Sí" ] && { notify-send -t 2000 -i "$ICON_RECORD" "Grabando" ffmpeg \ -loglevel error \ -y \ -thread_queue_size 4096 \ $audio \ -f x11grab \ -draw_mouse 1 \ -s "${width}x$height" \ -r "$fps" \ -i "$DISPLAY.0+$offX,$offY" \ -pix_fmt yuv420p \ -q:v 0 \ "$output" & echo $! > /tmp/blaze-pid }