Snail/bin/nvrun

33 lines
789 B
Bash
Executable File

#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:$PATH
TIMEOUT=10 # wait timeout for X server start
let INTEL_IF_FAIL=1 # run on Intel if nVidia fails
LOCK_FILE=/tmp/.snail.lock
FIFO_FILE=/tmp/.snail.fifo
{
echo -n > $FIFO_FILE &
flock -w $TIMEOUT -s 9
if [ 0 -eq $? ]; then
echo "Running $@ on nVidia"
export LD_LIBRARY_PATH=/usr/lib/snail:/usr/lib/snail/lib
[ -f /usr/lib/snail/libGL.so ] && LD_PRELOAD=$LD_PRELOAD:/usr/lib/snail/libGL.so
[ -f /usr/lib/snail/libnvidia-tls.so ] && LD_PRELOAD=$LD_PRELOAD:/usr/lib/snail/libnvidia-tls.so
snail.vglrun -d :1 "$@"
echo "Application $@ was performed on nVidia"
elif [ 0 -ne $INTEL_IF_FAIL ]; then
echo "Running $@ on Intel"
"$@"
echo "Application $@ was performed on Intel"
fi
flock -u 9
} 9>$LOCK_FILE