View previous topic :: View next topic |
Author |
Message |
ON7AMI n00b

Joined: 26 Feb 2019 Posts: 11 Location: Belgium
|
Posted: Tue Mar 05, 2019 1:20 pm Post subject: [Solved] How to start desktop program from tty prompt |
|
|
Hello all,
Is it possible to start a x-desktop program from a tty prompt on raspberry Pi 64
On Debian I could do:
Code: | DISPLAY=:0
./MediaPlayer &! |
in a Putty SSH session to start my application on the graphic desktop
If I try this on Gentoo I get a message
Code: | qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display. |
P.S. I tried all numbers from, 0 to 9
Anyone got an idea whats wrong?
Greets
Jean Paul
Last edited by ON7AMI on Wed Mar 06, 2019 6:32 am; edited 1 time in total |
|
Back to top |
|
 |
mike155 Advocate

Joined: 17 Sep 2010 Posts: 2564 Location: Frankfurt, Germany
|
Posted: Tue Mar 05, 2019 3:35 pm Post subject: |
|
|
Which shell do you use? Your code won't work if you use bash. If you use bash, it would be either
Code: | export DISPLAY=":0"
./MediaPlayer
|
or
Code: | DISPLAY=":0" ./MediaPlayer |
But this will work only if an X server is listening at '/tmp/.X11-unix/X0'.
Look at this article, please: https://askubuntu.com/questions/432255/what-is-the-display-environment-variable.
After that, find the socket where your X server is listening (either a UNIX socket or a TCP socket) and set the DISPLAY environment variable accordingly. There's no magic behind DISPLAY. It's just a pointer to the socket. |
|
Back to top |
|
 |
Jaglover Watchman


Joined: 29 May 2005 Posts: 7799 Location: Saint Amant, Acadiana
|
|
Back to top |
|
 |
Leio Developer


Joined: 27 Feb 2003 Posts: 494 Location: Estonia
|
Posted: Tue Mar 05, 2019 4:29 pm Post subject: |
|
|
Are you sure it is :0 or :1 or such? Maybe you ended up with a system with :0.0 or such? Can you check on the device (with temporarily attached keyboard?) what the DISPLAY env is there, or find out from logs? If you can launch a terminal with keyboard/mouse, you can check with echo $DISPLAY
Also, are you trying to run these via DISPLAY set with the same user that runs the X session (the desktop sessions user, not root if that's just from suid X)? Otherwise issues with permissions get in the way
@ON7AMI: bash at least for me exports it fine for the whole session without explicit "export". For ebuilds we also don't write "export" for variables to export into saved environment file, because that's the default; instead we need to declare others "local" to avoid it.
@Jaglover: He seems to want to start something on the actual devices X, not use remote X (for which I would never suggest a port 6000 thing instead of secure ssh). DISPLAY=:0 gui_app ought to work fine if the running X there is :0 _________________ GNOME team lead; GStreamer; MIPS/ARM64 |
|
Back to top |
|
 |
mike155 Advocate

Joined: 17 Sep 2010 Posts: 2564 Location: Frankfurt, Germany
|
Posted: Tue Mar 05, 2019 5:02 pm Post subject: |
|
|
Quote: | bash at least for me exports it fine for the whole session without explicit "export". |
Sorry, but I don't buy that.
Please execute the statements below:
Code: | set | grep SHELL # Make sure you're running bash (SHELL should be /bin/bash)
unset DISPLAY
xterm # 1) Won't work
DISPLAY=":0"
xterm # 2) Won't work
export DISPLAY=":0"
xterm # 3) Should work |
It may be that 1 AND 2 work, because xterm uses some other mechanism to connect to the X server.
But I really doubt that 1 does NOT work and 2 works. It that's really the case, I would like to know how/why.
Please note: I don't want to start a flamewar. But I think it's crucial to understand how bash works and how X clients connect to the X server. Therefore, I'd really be interested to hear if someone has a setup where 1 doesn't work and 2 works. |
|
Back to top |
|
 |
Leio Developer


Joined: 27 Feb 2003 Posts: 494 Location: Estonia
|
Posted: Tue Mar 05, 2019 6:47 pm Post subject: |
|
|
You are right, export or same command call is necessary. I got confused by echo $DISPLAY working, but program does need the export to see it. _________________ GNOME team lead; GStreamer; MIPS/ARM64 |
|
Back to top |
|
 |
Hu Moderator

Joined: 06 Mar 2007 Posts: 16472
|
Posted: Wed Mar 06, 2019 1:28 am Post subject: |
|
|
One thing that can confuse the situation is that if a variable is already exported, you can assign a new value to it and the exported flag will not change: Code: | bash-4.4$ env | grep DISPLAY
DISPLAY=:0
bash-4.4$ DISPLAY=x
bash-4.4$ env | grep DISPLAY
DISPLAY=x
bash-4.4$ unset DISPLAY
bash-4.4$ env | grep DISPLAY
bash-4.4$ DISPLAY=x
bash-4.4$ env | grep DISPLAY
bash-4.4$ export DISPLAY
bash-4.4$ env | grep DISPLAY
DISPLAY=x
bash-4.4$ |
|
|
Back to top |
|
 |
ON7AMI n00b

Joined: 26 Feb 2019 Posts: 11 Location: Belgium
|
Posted: Wed Mar 06, 2019 6:32 am Post subject: |
|
|
mike155 wrote: | Which shell do you use? Your code won't work if you use bash. If you use bash, it would be either
Code: | export DISPLAY=":0"
./MediaPlayer
|
or
Code: | DISPLAY=":0" ./MediaPlayer |
But this will work only if an X server is listening at '/tmp/.X11-unix/X0'.
...There's no magic behind DISPLAY. It's just a pointer to the socket. |
tnx, the shell is BASH, it was the missing keyword "export" who did it
So, it's working fine now.
Thanks a lot. |
|
Back to top |
|
 |
|