Acabei usando o arquivo .profile
e alterando meu código para estes:
Em .profile
:
if [ "$RECORDISRUNNING" != "1" ]; then
export RECORDISRUNNING=1
/home/swuser/sleep.sh &
fi
Em sleep.sh
:
#!/bin/sh
# sleep for 30 seconds then call record.sh
sleep 30
/home/swuser/scripts/record.sh &
Em record.sh
#!/bin/sh
# Check to see if there is a display, and if not, exit with error code of 1
if [ -z "$DISPLAY" ]; then
exit 1
fi
# Export the main display
export DISPLAY=0.0
# Set variable now to todays date and the time right now in Hours-Minutes-Seconds_Month-Day-Year
now=$(date +'%H-%M-%S_%m-%d-%Y')
# Start recording using ffmpeg at 5fps with a time limit of 300 seconds(Five Minutes) to file $now
ffmpeg -f x11grab -s 1024x768 -r 5 -t 300 -i :0.0 /home/swuser/Videos/$now.mp4
# Call the script again (to continually record in 300 second increments)
/home/swuser/scripts/record.sh &
E isso encerra tudo.