Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #!/bin/sh
  2. # /etc/init.d/fbdev
  3. ### BEGIN INIT INFO
  4. # Provides: fbdev
  5. # Required-Start: $remote_fs $syslog
  6. # Required-Stop: $remote_fs $syslog
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Short-Description: Start X server on HDMI, if plugged, otherwise TFT, at boot time
  10. # Description: Start X Server at boot time.
  11. ### END INIT INFO
  12.  
  13. # Set the FBUSER variable to the name of the user to start Xserver under
  14. FBUSER="pi"
  15.  
  16. # Set the LAYOUT variable with which to start the Xserver under
  17. LAYOUT="TFT"
  18.  
  19. PLUGGED=$(tvservice -s | grep -i hdmi)
  20.  
  21. if [ -n "$PLUGGED" ]
  22. then
  23. LAYOUT="HDMI"
  24. su $FBUSER -c "con2fbmap 1 0"
  25. su $FBUSER -c "gpio -g mode 18 pwm"
  26. else
  27. su $FBUSER -c "con2fbmap 1 1"
  28. fi
  29.  
  30. eval cd ~$FBUSER
  31.  
  32. case "$1" in
  33. start)
  34. su $FBUSER -c "startx -- -layout '$LAYOUT'"
  35. echo "Starting Xserver for $FBUSER "
  36. ;;
  37. stop)
  38. pkill xinit
  39. echo "Xserver stopped"
  40. ;;
  41. *)
  42. echo "Usage: /etc/init.d/fbdev {start|stop}"
  43. exit 1
  44. ;;
  45. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement