Skip to content

Instantly share code, notes, and snippets.

@stenuto
Created June 18, 2024 20:56
Show Gist options
  • Save stenuto/a54eab4fc698e283e82be23dfbfb0a1d to your computer and use it in GitHub Desktop.
Save stenuto/a54eab4fc698e283e82be23dfbfb0a1d to your computer and use it in GitHub Desktop.
Timelapse script
#!/bin/bash
# Check if interval argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 -int <interval_in_seconds>"
exit 1
fi
# Extract the interval value
interval=$2
counter=1
while true; do
# Take a fullscreen screenshot and save it to the current directory with a sequential name
screencapture -x ./${counter}.png
# Increment the counter
((counter++))
# Wait for the specified interval
sleep "$interval"
done
@Davydx7
Copy link

Davydx7 commented Jun 20, 2024

small fix @stenuto , the script is currently not actually checking for the second argument

# Check if interval argument is provided
if [ "$1" != "-int" ] || [ -z "$2" ]; then
  echo "Usage: $0 -int <interval_in_seconds>"
  exit 1
fi
...

alternatively, the -int flag can be removed

# Check if interval argument is provided
if [ -z "$1" ]; then
  echo "Usage: $0 <interval_in_seconds>"
  exit 1
fi

# Extract the interval value
interval=$1
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment