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
|
|
|
|
2012-03-21 00:15:32 +04:00
|
|
|
TIMEOUT=10 # 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
|
2011-12-25 02:34:49 +04:00
|
|
|
|
2011-12-24 00:15:11 +04:00
|
|
|
|
2012-03-20 16:46:24 +04:00
|
|
|
{
|
2012-03-21 00:15:32 +04:00
|
|
|
echo -n > $FIFO_FILE &
|
2012-03-20 16:46:24 +04:00
|
|
|
flock -w $TIMEOUT -s 9
|
2011-12-24 00:15:11 +04:00
|
|
|
|
2012-03-20 16:46:24 +04:00
|
|
|
if [ 0 -eq $? ]; then
|
|
|
|
echo "Running $@ on nVidia"
|
2012-04-01 19:34:26 +04:00
|
|
|
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
|
2012-04-01 20:05:04 +04:00
|
|
|
snail.vglrun -d :1 "$@"
|
2012-03-20 16:46:24 +04:00
|
|
|
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 "Running $@ on Intel"
|
|
|
|
"$@"
|
|
|
|
echo "Application $@ was performed on Intel"
|
|
|
|
fi
|
2011-12-24 00:15:11 +04:00
|
|
|
|
2012-03-21 00:15:32 +04:00
|
|
|
flock -u 9
|
|
|
|
|
|
|
|
} 9>$LOCK_FILE
|