Advertisement
Lekensteyn

Untitled

Aug 6th, 2011
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #!/bin/bash
  2. # "a daemon"
  3. echo "PID to be used with kill: $$"
  4.  
  5. OPTIRUNS='/usr/bin/optirun /usr/bin/optirun32 /usr/bin/optirun64'
  6. OPTIRUNS='/tmp/optirun'
  7. # communication file
  8. fifo="/tmp/bumblebee.fifo"
  9.  
  10. mkfifo "$fifo"
  11. chmod 620 "$fifo"
  12. chgrp bumblebee "$fifo"
  13.  
  14. start_x() {
  15. echo Starting X...
  16. if [ -e /tmp/.X8-lock ]; then
  17. echo "Is already running"
  18. else
  19. LD_LIBRARY_PATH=/usr/lib/nvidia-current \
  20. /usr/bin/X \
  21. -ac -config /etc/X11/xorg.conf.nvidia \
  22. -sharevts -modulepath /usr/lib/nvidia-current/xorg,/usr/lib/xorg/modules \
  23. -nolisten tcp :8
  24. echo Started X
  25. fi
  26. }
  27. stop_x() {
  28. echo Stopping X...
  29. if [ -e /tmp/.X8-lock ]; then
  30. kill -SIGTERM $(</tmp/.X8-lock)
  31. echo Stopped X
  32. else
  33. echo "Not started."
  34. fi
  35. }
  36. while :; do
  37. # for some reason, : < "$fifo" failed
  38. cat "$fifo" > /dev/null
  39. # note: the below does not really work since optirun is still active when receiving a message
  40. if pidof -x $OPTIRUNS; do
  41. start_x
  42. else
  43. stop_x
  44. fi
  45. done
  46.  
  47. rm -f "$fifo"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement