Skip to content

Instantly share code, notes, and snippets.

@benyaminl
Created April 19, 2023 13:51
Show Gist options
  • Save benyaminl/09ab88441531f75efcaaec01f521abfd to your computer and use it in GitHub Desktop.
Save benyaminl/09ab88441531f75efcaaec01f521abfd to your computer and use it in GitHub Desktop.
Recording ffmpeg toggle from xfce keyboard map. If there are running ffmpeg for it, it will be killed.
#!/bin/sh
record=$(pgrep -a ffmpeg | grep x11grab | awk "{print \$1}" | xargs -I {} echo {})
if [ -z $record ];
then
xwininfo | {
while IFS=: read -r k v; do
case "$k" in
*"Absolute upper-left X"*) x=$v;;
*"Absolute upper-left Y"*) y=$v;;
*"Border width"*) bw=$v ;;
*"Width"*) w=$v;;
*"Height"*) h=$v;;
esac
done
for i in 3 2 1; do echo "$i"; sleep 1; done
ffmpeg -y -f x11grab -framerate 24 \
-video_size "$((w))x$((h))" \
-i "+$((x+bw)),$((y+bw))" "$(date +%F\ %H:%M:%S).mp4" &
}
else
kill $record
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment