No Display Name And No $display Environment Variable Using Tkinter On Raspberry Pi B+ From Boot Shell Script
Solution 1:
I don't think a problem with your code is causing your error. Especially since you said:
I want to add that my code runs fine from idle, fine from terminal
Let me suggest that while cron
is an excellent tool for scheduling recurring jobs, which I use constantly (every minute forever, actually), it may not be the best tool to meet your needs here.
Since you want to run your program when your PI boots, and your program runs in X, why don't you add it to the LXDE autostart file? Using nano, or the text editor of your choice, edit the following file: For older Raspbian builds:
sudo nano /etc/xdg/lxsession/LXDE/autostart
Or for current Rasbian builds:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
Add the following line, and then save the file:
@sh /home/pi/launcher.sh
Or if you want a terminal window also, for debugging:
@lxterminal --command='sh /home/pi/launcher.sh'
Also, you can make shell scripts and python scripts executable with two simple steps.
- Add a hashbang to the very first line of the script.
Python:
#!/usr/bin/python2
or#!/usr/bin/python3
Shell:#!/bin/sh
or maybe#!/bin/bash
Mark the script as executable. From the command line enter:
chmod +X ./myscript.sh
orsudo chmod 755 ./myscript.sh
Solution 2:
Adam's answer is great, but a recent change in Raspian means you need to edit a different LXDE-pi file:
sudo nano ~/.config/lxsession/LXDE-pi/autostart
I did that and now it works for me.
Solution 3:
Now the system autostart file is located here: /etc/xdg/lxsession/LXDE-pi/
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
Post a Comment for "No Display Name And No $display Environment Variable Using Tkinter On Raspberry Pi B+ From Boot Shell Script"