diff --git a/recorder.sh b/recorder.sh index 7801683..e96eab1 100755 --- a/recorder.sh +++ b/recorder.sh @@ -12,6 +12,12 @@ if pidof ffmpeg time=$(date +%F%T) + for p in $(pgrep -t $(cat /sys/class/tty/tty0/active)); + do + d=$(awk -v RS='\0' -F= '$1=="DISPLAY" {print $2}' /proc/$p/environ 2>/dev/null); + [[ -n $d ]] && break; + done; + # only start recording if we give a width (e.g we press escape to get out of slop - don't record) width=${#W} @@ -21,8 +27,8 @@ if pidof ffmpeg # records without audio input # for audio add "-f alsa -i pulse" to the line below (at the end before \, without "") - ffmpeg -f x11grab -s "$W"x"$H" -framerate 60 -thread_queue_size 512 -i $DISPLAY.0+$X,$Y \ + ffmpeg -f x11grab -s "$W"x"$H" -framerate 60 -thread_queue_size 512 -i $d.0+$X,$Y \ -vcodec libx264 -qp 18 -preset ultrafast \ - ~/Videos/recording-$time.mp4 + ~/Videos/recording-$time.mp4 || notify-send 'Recording failed!' --icon=dialog-information fi fi