-
-
Save FlokiTV/d1cfdad98e28511d19047eaf337a1c21 to your computer and use it in GitHub Desktop.
xvfb-run-safe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# allow settings to be updated via environment | |
: "${xvfb_lockdir:=$HOME/.xvfb-locks}" | |
: "${xvfb_display_min:=99}" | |
: "${xvfb_display_max:=599}" | |
mkdir -p -- "$xvfb_lockdir" || exit | |
i=$xvfb_display_min # minimum display number | |
while (( i < xvfb_display_max )); do | |
if [ -f "/tmp/.X$i-lock" ]; then | |
(( ++i )); continue | |
fi | |
exec 5>"$xvfb_lockdir/$i" || continue | |
if flock -x -n 5; then | |
exec xvfb-run --server-num="$i" "$@" || exit | |
fi | |
(( i++ )) | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment