Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # /etc/init.d/fbdev
- ### BEGIN INIT INFO
- # Provides: fbdev
- # Required-Start: $remote_fs $syslog
- # Required-Stop: $remote_fs $syslog
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Start X server on HDMI, if plugged, otherwise TFT, at boot time
- # Description: Start X Server at boot time.
- ### END INIT INFO
- # Set the FBUSER variable to the name of the user to start Xserver under
- FBUSER="pi"
- # Set the LAYOUT variable with which to start the Xserver under
- LAYOUT="TFT"
- PLUGGED=$(tvservice -s | grep -i hdmi)
- if [ -n "$PLUGGED" ]
- then
- LAYOUT="HDMI"
- su $FBUSER -c "con2fbmap 1 0"
- su $FBUSER -c "gpio -g mode 18 pwm"
- else
- su $FBUSER -c "con2fbmap 1 1"
- fi
- eval cd ~$FBUSER
- case "$1" in
- start)
- su $FBUSER -c "startx -- -layout '$LAYOUT'"
- echo "Starting Xserver for $FBUSER "
- ;;
- stop)
- pkill xinit
- echo "Xserver stopped"
- ;;
- *)
- echo "Usage: /etc/init.d/fbdev {start|stop}"
- exit 1
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement