Luke here! Although I’ve been using Linux as my main OS for quite a while, I’m still pretty much a noob when it comes to using it. Sorry.
I have a Raspberry Pi that I’m trying to set up with the PiTFT display from Adafruit. I believe I’ve got it all set up driver-wise, but to make the GUI (Which I believe is called X, but correct me if I’m wrong) show up on the screen, I have to type “startx” into terminal, and then everything shifts over to the other screen.
Because in my final project that I’m using this pi for, (A gameboy-type device that could run emulators and native pi games – https://learn.adafruit.com/pigrrl-raspberry-pi-gameboy/overview) I will not have a keyboard hooked up, this could be a bit difficult. So, my solution was to make a script that would run this command automatically.
I created a file in /etc/init.d called startguiscript.sh that contained the single line “startx”, and rebooted the pi. Didn’t work. After a bit of googling, I found that I needed to run the command “sudo update-rc.d startguiscript.sh defaults”. I did this, and got a warning because I didn’t add in LSB tags, but after another google search, I believe that this is irrelevant and doesn’t really mean anything.
After rebooting again, it still doesn’t run automatically. HELP! (Please)
Also, apologies if I’m not posting some vital and important bug report or log file. Please yell at me, and I’ll post it.
Is the script marked as executable? If not, do
chmod +x script.sh where “script.sh” is the name of your script. Also, do you have the she-bang on the script? The very first line should be
#!/bin/bash or wherever your bash is located if different than
I don’t use a Raspberry Pi but the above two suggestions are general Linux suggestions which it uses.
According to this link you need to also run “sudo update-rc.d /etc/init.d/SCRIPTNAME defaults” – this will set it up to start on startup.
I’d strongly recommend however modifying the script so it can take the parameters start and stop. This would be quite easy – something like
> #! /bin/bash > > case "$1" in > start) > echo "Starting X" > /path/to/startx **** <= Change the path here) > ;; > stop) > echo "Stopping X" > /usr/bin/killall X > ;; > *) > echo "Usage $0 start|stop"; > exit 1 esac > > exit 0