2018-09-24 15:23:46 +00:00
|
|
|
#!/bin/sh
|
2018-04-11 06:08:43 +00:00
|
|
|
|
2018-09-24 15:23:46 +00:00
|
|
|
# Usage:
|
|
|
|
# `record`: Ask for recording type via dmenu
|
|
|
|
# `record screencast`: Record both audio and screen
|
|
|
|
# `record video`: Record only screen
|
|
|
|
# `record audio`: Record only audio
|
|
|
|
# `record kill`: Kill existing recording
|
|
|
|
#
|
|
|
|
# If there is already a running instance, user will be prompted to end it.
|
2018-04-11 06:08:43 +00:00
|
|
|
|
2018-09-24 15:23:46 +00:00
|
|
|
updateicon() { \
|
|
|
|
echo "$1" > ~/.recordingicon
|
|
|
|
pkill -RTMIN+9 i3blocks
|
|
|
|
}
|
2018-08-04 17:49:54 +00:00
|
|
|
|
2018-09-24 15:23:46 +00:00
|
|
|
killrecording() {
|
|
|
|
kill -9 "$(cat ~/.recordingpid)"
|
|
|
|
rm -f ~/.recordingpid
|
|
|
|
updateicon ""
|
|
|
|
pkill -RTMIN+9 i3blocks
|
|
|
|
exit
|
|
|
|
}
|
2018-04-11 06:08:43 +00:00
|
|
|
|
2018-09-24 15:23:46 +00:00
|
|
|
screencastpulse() { \
|
|
|
|
ffmpeg -y \
|
|
|
|
-f x11grab \
|
|
|
|
-framerate 60 \
|
|
|
|
-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
|
|
|
|
-i :0.0 \
|
|
|
|
-f alsa -i default \
|
|
|
|
-r 30 \
|
|
|
|
-c:v libx264rgb -crf 0 -preset ultrafast -c:a flac \
|
|
|
|
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mkv" &
|
|
|
|
echo $! > ~/.recordingpid
|
|
|
|
updateicon "⏺️🎙️"
|
|
|
|
}
|
|
|
|
|
|
|
|
screencastalsa() { \
|
|
|
|
ffmpeg -y \
|
|
|
|
-f x11grab \
|
|
|
|
-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
|
|
|
|
-i :0.0 \
|
|
|
|
-thread_queue_size 1024 \
|
|
|
|
-f alsa -ar 44100 -i hw:1 \
|
|
|
|
-c:v libx264 -r 30 -c:a flac \
|
|
|
|
"$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mkv" &
|
|
|
|
echo $! > ~/.recordingpid
|
|
|
|
updateicon "⏺️"
|
|
|
|
}
|
|
|
|
|
|
|
|
video() { ffmpeg \
|
|
|
|
-f x11grab \
|
|
|
|
-s $(xdpyinfo | grep dimensions | awk '{print $2;}') \
|
|
|
|
-i :0.0 \
|
|
|
|
-c:v libx264 -qp 0 -r 30 \
|
|
|
|
"$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" &
|
|
|
|
echo $! > ~/.recordingpid
|
|
|
|
updateicon "⏺️"
|
|
|
|
}
|
|
|
|
|
|
|
|
audiopulse() { \
|
|
|
|
ffmpeg \
|
|
|
|
-f alsa -i default \
|
|
|
|
-c:a flac \
|
2018-09-29 19:51:26 +00:00
|
|
|
"$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" &
|
2018-09-24 15:23:46 +00:00
|
|
|
echo $! > ~/.recordingpid
|
|
|
|
updateicon "🎙️"
|
|
|
|
}
|
|
|
|
|
|
|
|
audioalsa() { \
|
|
|
|
ffmpeg -y \
|
|
|
|
-f alsa -ar 44100 -i hw:1 \
|
|
|
|
"$HOME/audio-$(date '+%y%m%d-%H%M-%S').mkv" &
|
|
|
|
echo $! > ~/.recordingpid
|
|
|
|
updateicon "🎙️"
|
|
|
|
}
|
|
|
|
|
|
|
|
askrecording() { \
|
|
|
|
printf "screencast\\nvideo\\naudio" | dmenu -i -p "Select recording style:"
|
|
|
|
}
|
2018-04-11 06:08:43 +00:00
|
|
|
|
|
|
|
asktoend() { \
|
2018-09-24 15:23:46 +00:00
|
|
|
response=$(printf "No\\nYes" | dmenu -i -p "Recording still active. End recording?") &&
|
|
|
|
[ "$response" = "Yes" ] && killrecording
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
screencast) screencastpulse;;
|
|
|
|
audio) audiopulse;;
|
|
|
|
video) video;;
|
|
|
|
kill) killrecording;;
|
|
|
|
*) ([ -f ~/.recordingpid ] && asktoend && exit) || askrecording;;
|
|
|
|
esac
|