Making FridgeGizmo run automatically

…or How to Get a Script to Run Automatically at the Auto-login on default Raspberry Pi Raspbian Linux.

I want to get my FridgeGizmo that displays local weather and global tweets on an LCD display to start itself up automatically when I plug it in, with no user intervention. I tinkered around with .profile files, but I could only get them to run when I manually opened a terminal session (by SSH from my laptop, in my case). This is no good. I wanted the Raspberry Pi to run my script to send text to the LCD display (via the Arduino) when the Pi logs itself in to the normal LXDE graphical environment. I don’t want it to run too soon (at boot, for example) because I need to be sure that it’s connected to the internet and that Apache and PHP are running, as they are needed to make FridgeGizmo work.

Here’s how I did it…

I opened a terminal window (SSH in my case, but a root terminal window on the Pi screen should work too). I navigated to the home folder of the default user – pi – by typing
cd /home/pi
at the command line.

I then created a new file called auto.desktop by typing
sudo nano auto.desktop
at the command line.

Into this file I pasted the following text:

[Desktop Entry]
Encoding=UTF-8
Name= Connect
Comment=Checks internet connectivity
Exec=lxterminal --command "/var/www/tweetwx.sh"
Terminal=true

and saved it using ctrl-O, ctrl-X. /var/www/tweetwx.sh is the path to the shell script which calls the PHP file that pulls weather and tweets from the internet and sends them to the Arduino and its LCD display.

I then had to make a directory inside the /home/pi/.config folder to put this file in by typing in the root command window:
cd /home/pi/.config
mkdir autostart

I then moved my auto.desktop file in there by using this command:
cd /home/pi
mv auto.desktop .config/autostart/

I then rebooted the Raspberry Pi, connected to the screenless and keyboardless Arduino, and soon weather and tweets started appearing on the LCD with no human intervention. Yay!

This entry was posted in Arduino, computers, hardware, Raspberry Pi, Raspbian and tagged , , , , . Bookmark the permalink.

Leave a Reply