Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # "a daemon"
- echo "PID to be used with kill: $$"
- OPTIRUNS='/usr/bin/optirun /usr/bin/optirun32 /usr/bin/optirun64'
- OPTIRUNS='/tmp/optirun'
- # communication file
- fifo="/tmp/bumblebee.fifo"
- mkfifo "$fifo"
- chmod 620 "$fifo"
- chgrp bumblebee "$fifo"
- start_x() {
- echo Starting X...
- if [ -e /tmp/.X8-lock ]; then
- echo "Is already running"
- else
- LD_LIBRARY_PATH=/usr/lib/nvidia-current \
- /usr/bin/X \
- -ac -config /etc/X11/xorg.conf.nvidia \
- -sharevts -modulepath /usr/lib/nvidia-current/xorg,/usr/lib/xorg/modules \
- -nolisten tcp :8
- echo Started X
- fi
- }
- stop_x() {
- echo Stopping X...
- if [ -e /tmp/.X8-lock ]; then
- kill -SIGTERM $(</tmp/.X8-lock)
- echo Stopped X
- else
- echo "Not started."
- fi
- }
- while :; do
- # for some reason, : < "$fifo" failed
- cat "$fifo" > /dev/null
- # note: the below does not really work since optirun is still active when receiving a message
- if pidof -x $OPTIRUNS; do
- start_x
- else
- stop_x
- fi
- done
- rm -f "$fifo"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement