Skip to content

Instantly share code, notes, and snippets.

@bdelacretaz
Last active July 9, 2019 11:47
Show Gist options
  • Save bdelacretaz/ed9aecb922a104eb6497954242b9b591 to your computer and use it in GitHub Desktop.
Save bdelacretaz/ed9aecb922a104eb6497954242b9b591 to your computer and use it in GitHub Desktop.
Restart multiple shell commands synchronously (example)
#!/bin/bash
# Run two video players more or less in sync
# assuming they start playing immediately and
# exit when done playing
while true
do
# Start all players in the background
# VLC settings: full screen, select the right display, quit after playback
/Applications/VLC.app/Contents/MacOS/VLC -f movie1.mov &
# Use AppleScript to run quicktime full screen
osascript play.scpt &
echo "Waiting for player jobs..."
jobsOutput="not empty"
while [[ -n "$jobsOutput" ]]
do
jobsOutput=$(jobs | grep -v ' Done')
sleep 1
done
echo "Done waiting."
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment