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

105 lines
2.3 KiB
Bash
Executable File

#!/bin/sh
M=$(bspc query -M --names)
NUM=$(echo "$M" | awk 'END{print NR}')
if [ "$NUM" = 1 ]; then
pant=-video_size 1366x768 -i :0.0
elif [ "$NUM" = 2 ]; then
pant=$()
fi
killrecording() {
recpid="$(cat /tmp/recordingpid)"
# kill with SIGTERM, allowing finishing touches.
kill -15 "$recpid"
rm -f /tmp/recordingpid
# even after SIGTERM, ffmpeg may still run, so SIGKILL it.
sleep 3
kill -9 "$recpid"
exit
}
screencast() { \
ffmpeg -y \
-thread_queue_size 4096 \
-f x11grab \
-framerate 60 \
-s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \
-i "$DISPLAY" \
-f alsa -ac 2 -i pulse \
-r 30 \
-c:v libx264rgb -crf 0 -preset ultrafast -c:a libfdk_aac \
"$HOME/vid/Screen/$(date -I).mkv" &
echo $! > /tmp/recordingpid
}
jacka() { \
ffmpeg -y \
-thread_queue_size 4096 \
-f jack -i jack_out.monitor \
-ac 2 -channel_layout stereo -async 1 \
-c:a libopus "$HOME/snd/Tape/$(date -I).opus"
echo $! > /tmp/recordingpid
}
jackv() {
ffmpeg -y \
-thread_queue_size 4096 \
-f jack -i ffmpeg \
-f x11grab \
-framerate 60 \
-s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \
-i "$DISPLAY" \
-r 30 \
-c:v libx264 -qp 0 -r 30 -c:a libfdk_aac \
"$HOME/vid/Screen/$(date -I).mkv" &
echo $! > /tmp/recordingpid
}
mute() {
ffmpeg -y \
-f x11grab \
-thread_queue_size 4096 \
-s "$(xdpyinfo | grep dimensions | awk '{print $2;}')" \
-i "$DISPLAY" \
-c:v libx264 -qp 0 -r 30 \
"$HOME/vid/$(date -I).mkv" &
echo $! > /tmp/recordingpid
}
audio() { \
ffmpeg -y \
-thread_queue_size 4096 \
-f pulse -i default \
-ac 2 -channel_layout stereo -async 1 \
-c:a flac \
"$HOME/snd/tape/$(date -I).mp3" &
echo $! > /tmp/recordingpid
}
askrecording() { \
choice=$(printf "Screencast\\nVideo\\nAudio\\nJack Screencast\\nJack Audio" | dmenu -i -w 200 -p " ")
case "$choice" in
"Screencast") screencast;;
"Video") mute;;
"Audio") audio;;
"Jack Screencast") jackv;;
"Jack Audio") jacka;;
esac
}
asktoend() { \
response=$(printf "No\\nSi" | dmenu -i -w 220 -p "Cortar? ") &&
[ "$response" = "Si" ] && killrecording
}
case "$1" in
"Screencast") screencast;;
"Video") mute;;
"Audio") audio;;
"Jack Screencast") jackv;;
"Jack Audio") jacka;;
*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;;
esac