Treader
Posts: 6
Joined: Mon Jul 25, 2016 11:08 pm

$DISPLAY troubles

Mon Jul 25, 2016 11:14 pm

Hi i am new to the PI and linux computing in general and i am having trouble assessing my display

first of all bash works fine and i can use x without problem but when i try and have another program use the display from bash it cannot locate it, when i call echo $DISPLAY i get a blank line, setting the DISPLAY variable to 0.0 in .bashrc does change the variable when i echo is but i am still unable to open any programs from terminal other than x
plz help im at a bit of a loss here


EDIT:

I am on the newest version of raspbian and am using an HDMI into display port adaptor,
i also attempted to use this in terminal to see if i could get my display info so i could manually set it but it returned a blank line

Code: Select all

for p in $(pgrep -t $(cat /sys/class/tty/tty0/active));
do 
    d=$(awk -v RS='\0' -F= '$1=="DISPLAY" {print $2}' /proc/$p/environ 2>/dev/null); 
    [[ -n $d ]] && break; 
done;
echo $d

User avatar
thagrol
Posts: 1780
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: $DISPLAY troubles

Tue Jul 26, 2016 3:51 pm

Try

Code: Select all

export DISPLAY=:0
in your bash session before starting the X app.

Also, the X server needs to be running, setting $DISPLAY and starting an X app isn't enough.
This space unintentionally left blank.

Treader
Posts: 6
Joined: Mon Jul 25, 2016 11:08 pm

Re: $DISPLAY troubles

Tue Jul 26, 2016 10:04 pm

I tried setting the display as suggested and echo $DISPLAY does return :0 but i am not trying to start an x program out of x but have tried multiple programs that should be able to use the display without x they all return various error messages even hello_dispmanx.bin fails

ex1:
hello_dispmanx a screen overlay included in pi software

Code: Select all

Open display[0]...
Display is 4 x 1036694296
Sleeping for 10 seconds 
no overlay is loaded


ex2:
hello_teapot included with pi
/*note that my gpu memory is set to 256 more than enough for hello_teapot

Code: Select all

Note: ensure you have sufficient gpu_mem configured
hello_teapot.bin: triangle.c:157: init_ogl: Assertion 'success >=0' failed.
Aborted

ex3:
ktop a kiosk browser/gui replacement

Code: Select all

Openbox-Message: Failed to open the display from the DISPLAY enviroment variable 

(kweb:1365): Gtk-WARNING **: cannot open display:  :0
ex4:
a raylib example core_basic_window

Code: Select all

INFO: Initializing raylib (v1.5.0)
WARNING: DOWNSCALING: Required screen size (800x450) is bigger than display size (0x0)
WARNING: downscale matrix generated, content will be rendered at 0x0
ERROR: Unable to attach EGL rendering content to EGL surface
but for some reason startx still functions im incredibly confused as to wtf is happening

User avatar
thagrol
Posts: 1780
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: $DISPLAY troubles

Wed Jul 27, 2016 1:30 am

I'm not familiar with those apps/demos. Can you post the commands you're using to launch them?

$DISPLAY is, I believe, specific to X11 so if an app/program is using it it likely needs an X server running.

Having had a quick google, I can offer the following suggestions:

Hello_teapot: try setting GPU memory to 128. This is what the documentation (https://www.raspberrypi.org/documentati ... -teapot.md) suggests. It's possible (but I haven't checked) that the code dates back to the original 256MB Pi 1 and can't cope with 256MB gpu memory.

ktop: Nothing obvious from a quick google however the error seems to be coming from kweb. It appears that kweb requires a running X server. Try launching it from within X (i.e. after running startx) or by

Code: Select all

xinit /path/to/ktop
from the command line.

raylib: no suggestions, sorry. Well other than suggesting you try asking in their forums.

As for startx, that's doing more than I suspect you think it is. The startx script does a number of things including starting the X server, the window manager, the desktop manager, etc. It does all this "behind the scenes" and just presents you with a working desktop.
This space unintentionally left blank.

Treader
Posts: 6
Joined: Mon Jul 25, 2016 11:08 pm

Re: $DISPLAY troubles

Wed Jul 27, 2016 2:32 am

Thank you the command you suggested worked on ktop and i can now run that, but i still cannot run the included hello_teapot or hello_dispmanx demos.

I am attempting to run hello_teapot by first navigating to /opt/vc/src/hello_pi/ then running the build script with ./rebuild.sh ; all demos build with no issue. then i navigate to the hello_teapot directory and type ./hello_teapot.bin whereupon the error i recorded previously is returned.

The examles that dont access the screen outside of terminal such as hello_world and hello_audio work but thoes that do such as hello_font fail to run

I really do appreciate the help so far as now ktop is working

Treader
Posts: 6
Joined: Mon Jul 25, 2016 11:08 pm

Re: $DISPLAY troubles

Thu Jul 28, 2016 12:57 pm

I am going to attempt to run hello_teapot off of a clean install later tonight I will record the results here for posterity

User avatar
popetes
Posts: 10
Joined: Fri Jan 31, 2014 8:14 am

Re: $DISPLAY troubles

Thu Jul 28, 2016 3:19 pm

Hi Treader,

How are you trying to run these commands? From a keyboard attached directly to the Pi or SSH-ing in? If it's the former than you indeed have a problem. If it's the latter, you should know that X fails to run commands coming from remote users (such as SSH). Sometimes the problem can be circumvented by adding

Code: Select all

DISPLAY=:0
in front of your command i.e.

Code: Select all

DISPLAY=:0 startx

Treader
Posts: 6
Joined: Mon Jul 25, 2016 11:08 pm

Re: $DISPLAY troubles

Thu Jul 28, 2016 7:25 pm

I am trying to run programs by ./program_name in the appropriate directory with a screen directly attached to they pi and keyboard connected by Bluetooth, but I will attempt with

Code: Select all

DISPLAY=:0 ./program_name
to see what happens


EDIT:

ok i tried that command same error qq
but when i tried a fresh install it worked flawlessly, im just gona give up on tracking this down and reinstall everything on the fresh install thanks for the help

Treader
Posts: 6
Joined: Mon Jul 25, 2016 11:08 pm

Re: $DISPLAY troubles

Sat Aug 13, 2016 2:33 am

I solved this quite a while ago but il just post this in case anyone has the same problem, i forgot i had the experimental opengl driver enabled in raspi-config and it was what was breaking everything

Return to “Troubleshooting”