Snail/bin/nvrun

37 lines
906 B
Plaintext
Raw Normal View History

2012-03-20 16:46:24 +04:00
#!/bin/bash
2011-12-24 00:15:11 +04:00
2012-03-20 16:46:24 +04:00
PATH=/usr/local/sbin:/usr/local/bin:$PATH
2011-12-24 00:15:11 +04:00
TIMEOUT=2 # wait timeout for X server start
2012-03-20 16:46:24 +04:00
let INTEL_IF_FAIL=1 # run on Intel if nVidia fails
2011-12-24 00:15:11 +04:00
2012-03-20 16:46:24 +04:00
LOCK_FILE=/tmp/.snail.lock
FIFO_FILE=/tmp/.snail.fifo
2012-03-20 16:46:24 +04:00
{
flock -w 0 -s 9
if [ 0 -ne $? ]; then
(nohup echo -n > $FIFO_FILE &>/dev/null)&
flock -w $TIMEOUT -s 9
fi
2011-12-24 00:15:11 +04:00
2012-03-20 16:46:24 +04:00
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"
2011-12-24 00:15:11 +04:00
2012-03-20 16:46:24 +04:00
elif [ 0 -ne $INTEL_IF_FAIL ]; then
echo "Failed to run $@ on nVidia ;-("
# echo "Running $@ on Intel"
# "$@"
# echo "Application $@ was performed on Intel"
2012-03-20 16:46:24 +04:00
fi
2011-12-24 00:15:11 +04:00
2012-03-21 00:15:32 +04:00
flock -u 9
} 9>$LOCK_FILE