#!/bin/bash LOCKFILE="$HOME/.mediawrap.lock" ( if ! flock -w 10 -x 200; then echo "Failed to get a lock!" exit 1 fi # Run the program "$@" &> /dev/null ) 200>"$LOCKFILE" # Cleanup so other programs can start rm -f "$LOCKFILE"