#!/bin/bash # # Script to move focus to presentation window, press the mouse button to go to # next slide; then revert focus back to the terminal window # The idea is to record the time of progressing slides # designed for laptop+projector where laptop has terminal and projector the presentation # section=$1 outfilecode=$2 outfile=${outfilecode}-Timing-${section}.txt lecture=$3 startslide=$4 op="s" # bash change-slide.bash CS ITS323Y11S2U01 Data-Communications-and-Networks 1 audioFile=${outfilecode}-Audio-${section}.flac audioRate=44100 audioBits=16 audioChannels=1 screenFile=${outfilecode}-Screen-${section}.m4v screenRate=2 screenSize=1024x768 screenOffset=1024,0 screenCodec=libx264 screenOptions=" -vpre lossless_ultrafast -threads 0 " # Record the microphone audio using SoX rec -q -r ${audioRate} -b ${audioBits} -c ${audioChannels} ${audioFile} & audioPID=$! # Record the screen using ffmpeg ffmpeg -v 0 -f x11grab -r ${screenRate} -s ${screenSize} -i :0.0+${screenOffset} -sameq -vcodec ${screenCodec} ${screenOptions} ${screenFile} & screenPID=$! # Window ID of the terminal where script is running termid=`xdotool getactivewindow` pres_x=1050; pres_y=10; currenttime=`date +%s`; starttime=${currenttime}; prevslide=${startslide}; function sec_to_time { s=$1 if [ $s -ge 3600 ] then h=`expr $s / 3600`; s=`expr $s % 3600`; else h=0; fi if [ $s -ge 60 ] then m=`expr $s / 60`; s=`expr $s % 60`; else m=0; fi printf "%02d:%02d:%02d" $h $m $s } echo ${currenttime} >> ${outfile} echo ${lecture} S 00:00:00 >> ${outfile} echo ${lecture} ${startslide} 00:00:00 >> ${outfile} while [ ${op} != "z" ] do read -n1 op currenttime=`date +%s`; seconds=`expr $currenttime - $starttime`; secs=`sec_to_time ${seconds}` if [ ${op} = "s" ] then echo ${lecture} F ${secs} >> ${outfile} read -p "Lecture Slide: " lecture startslide prevslide=${startslide} echo ${currenttime} >> ${outfile} echo ${lecture} S ${secs} >> ${outfile} echo ${lecture} ${startslide} ${secs} >> ${outfile} elif [ ${op} = "f" ] then xdotool mousemove $pres_x $pres_y xdotool click 1 xdotool windowactivate $termid currentslide=`expr ${prevslide} + 1`; prevslide=${currentslide}; echo ${lecture} ${currentslide} ${secs} >> ${outfile} elif [ ${op} = "b" ] then xdotool mousemove $pres_x $pres_y xdotool click 3 xdotool windowactivate $termid currentslide=`expr ${prevslide} - 1`; prevslide=${currentslide}; echo ${lecture} ${currentslide} ${secs} >> ${outfile} elif [ ${op} = "r" ] then echo ${lecture} ${currentslide} ${secs} >> ${outfile} elif [ ${op} = "x" ] then read -p "Example: " example echo ${example} X ${secs} >> ${outfile} elif [ ${op} = "w" ] then read -p "URL: " example echo ${example} W ${secs} >> ${outfile} elif [ ${op} = "z" ] then echo ${lecture} F ${secs} >> ${outfile} kill -INT ${audioPID} kill -INT ${screenPID} sleep 5 else read -p "File: " example echo ${example} O ${secs} >> ${outfile} fi done exit