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-20 16:46:24 +04:00
|
|
|
TIMEOUT=5 # wait timeout for X server start
|
|
|
|
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
|
|
|
SERVICE=/etc/init.d/snail-xserver
|
|
|
|
PROC=nvrun
|
2011-12-25 02:34:49 +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
|
|
|
{
|
|
|
|
echo -n >$FIFO_FILE
|
|
|
|
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"
|
|
|
|
LD_PRELOAD="/usr/lib/opengl/nvidia/lib/libGL.so:/usr/lib/opengl/nvidia/lib/libnvidia-tls.so" snail.vglrun -d :1 "$@"
|
|
|
|
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-20 16:46:24 +04:00
|
|
|
} 9 > $LOCK_FILE
|