Skip to content

Instantly share code, notes, and snippets.

@fallwith
Created December 3, 2018 23:10
Show Gist options
  • Save fallwith/218a5f7ccebbd70afaa364b1cc55d19a to your computer and use it in GitHub Desktop.
Save fallwith/218a5f7ccebbd70afaa364b1cc55d19a to your computer and use it in GitHub Desktop.
Run caffeinate for the duration of an ffmpeg process
#!/usr/bin/env bash
set -euo pipefail
ffmpeg_pid=$(ps auwx | grep ffmpeg | grep -v grep | awk '{print $2}')
if [ "$ffmpeg_pid" == "" ]; then
echo "Cannot find an ffmpeg pid!"
exit -1
fi
echo "Caffeinating while pid $ffmpeg_pid runs..."
caffeinate -imsw $ffmpeg_pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment