Snail/bin/nvrun

37 lines
906 B
Bash
Executable File

#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:$PATH
TIMEOUT=2 # 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
{
flock -w 0 -s 9
if [ 0 -ne $? ]; then
(nohup echo -n > $FIFO_FILE &>/dev/null)&
flock -w $TIMEOUT -s 9
fi
if [ 0 -eq $? ]; then
echo "Running $@ on nVidia"
export LD_LIBRARY_PATH=/usr/lib/snail
LD_PRELOAD="/usr/lib/snail/lib32/libGL.so.1 \
/usr/lib/snail/lib32/libnvidia-tls.so \
/usr/lib/snail/lib32/libnvidia-core.so" \
snail.vglrun -d :8293 "$@" 2>/dev/null
echo "Application $@ was performed on nVidia"
elif [ 0 -ne $INTEL_IF_FAIL ]; then
echo "Failed to run $@ on nVidia ;-("
# echo "Running $@ on Intel"
# "$@"
# echo "Application $@ was performed on Intel"
fi
flock -u 9
} 9>$LOCK_FILE