dm-scripts/dm-recording/dm-recording.sh
2019-11-05 22:51:01 +01:00

67 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
if ! hash dmenu 2>/dev/null; then
notify-send "Error" "dmenu is not installed. Aborting."
echo "dmenu is not installed."
echo "Did you really try to run a dmenu utility without having dmenu installed?"
echo "Aborting."
exit 1
fi
if ! hash ffmpeg 2>/dev/null; then
notify-send "Error" "ffmpeg is not installed.\n\nAborting."
echo "ffmpeg is not installed."
echo "Aborting."
exit 1
fi
if ! hash slop 2>/dev/null; then
notify-send "Error" "slop is not installed.\n\nAborting."
echo "slop is not installed."
echo "slop is used to select the windows and regions."
echo "Aborting."
exit 1
fi
if ! ldconfig -p | grep libxcb >/dev/null; then
notify-send "Error" "libxcb is not installed.\n\nffmepg requires libxcb for it's x11grab option.\n\nAborting."
echo "libxcb is not installed."
echo "ffmepg requires libxcb for it's x11grab option."
echo "Aborting."
exit 1
fi
IFS=$'\n'
options="Fullscreen\nSelection"
choice=$(echo -e $options | sort | dmenu -p "Record" -i)
if [ -z $choice ]; then
exit
fi
case $choice in
"Fullscreen")
echo "Recording fullscreen"
file=$(mktemp -u /tmp/recording_XXXXXX.mp4)
notify-send --icon=panel/simplescreenrecorder-recording -t 900 'Recording starts' 'as soon as this notification closes'
sleep 1
ffmpeg -f x11grab -framerate 20 -video_size 1366x768 -i :0.0 $file
notify-send --icon=panel/simplescreenrecorder-paused 'Recording stopped'
ln -sf $file /tmp/recording_latest.mp4
;;
"Selection")
# need IFS = ' ' for read to be able to split the arguments
IFS=$' '
echo "Recording region"
read -r x y w h <<< $(slop -f "%x %y %w %h" -q -l -c 0.3,0.4,0.6,0.4 )
file=$(mktemp -u /tmp/recording_XXXXXX.mp4)
notify-send --icon=panel/simplescreenrecorder-recording -t 900 'Recording starts' 'as soon as this notification closes'
sleep 1
ffmpeg -f x11grab -framerate 20 -show_region 1 -video_size "${w}x${h}" -i ":0.0+${x},${y}" $file
notify-send --icon=panel/simplescreenrecorder-paused 'Recording stopped'
ln -sf $file /tmp/recording_latest.mp4
;;
*)
exit
;;
esac