Can't connect to Xserver
Hello all,
I am trying to pop up a messagebox in KDE4 from a background process. In order to test this, I have opened a real console (CTRL-ALT-F1) and su-ed to root. According to ps ax | grep X, X is running on display :0 and VT8: /usr/bin/X :0 vt8 -br -nolisten tcp -auth /var/run/xauth/A:0-9tDrka Now my problem is that I can't connect to the X server from a console. This is the error message that I get when entering this command: export DISPLAY=:0 && kdialog --msgbox "Hello world" returns: kdialog: cannot connect to xserver :0 Thinking that this might have to do something with allowed connections, I tried to set xhost: export DISPLAY=:0 && xhost +localhost which returns xhost: unable to open display ":0" For DISPLAY I tried :0, :1, :0.0, :0.1, :1.0, :1,1, but to no avail. From a virtual console (pts/0) it is no problem to pop up message boxes. I am running Debian Squeeze, KDE 4.4.5, kernel 2.6.32-5-amd64 Anyone who has some tips on how to accomplish this, or how to find out which DISPLAY to use? jlinkels |
Im not so sure about this but what about:
Code:
export DISPLAY=/usr/bin/X :0 && kdialog --msgbox "Hello world" Code:
export DISPLAY=/usr/bin/X :0 vt8 -br -nolisten tcp -auth /var/run/xauth/A:0-9tDrka && kdialog --msgbox "Hello world" Regards |
xhost must be executed in a terminal window and after that you can try to access it from your console.
executing xhost in the console will not work (it is not allowed to modify access outside of the X windows) |
pan64: Something is starting to dawn now.
Console is considered something different than Xterm. Xterm is able to connect to the Xserver, but Console cannot because it is an external connection. So from Xterm the xhost command has to be issued, and then Console should be able to connect? Let me experiment with that later. jlinkels |
xhost is used to set access control. By default the owner of the xserver (the user who started that session) will be able to modify it. Xterm is started within the session, so there is no problem with it, but when you want to start something from the console....
So you need to switch off access control - that is xhost +, you can execute it in the Xterm window - and than you can make connections from outside. in the real unix/linux life the X windows system is a client/server pair of applications, the Xserver itself is owned by root, and is usually named X or Xorg. It is only used to draw the content on the display. The client side is called session manager and this is owned by the user. All the applications within a session connect to the session manager, and the manager takes care about the access rights (to itself). |
Good, thanks for pointing me in the right direction.
What I did is this: I am logged in into KDE as jlinkels In Xterm I issued the command xhost +localhost Then in Console (TTY1), logged in as jlinkels, the kdialog command succeeded. However, as root it did not. Which is understandable according to the text in your post. When I tried: root# su - jlinkels -c "export DISPLAY=:0 && kdialog \"Hello\"" this worked as well. The script I am writing will be running with root credentials. So by using the su command and specifying this user, I can pop up a dialog for this user. Would that be the correct approach? jlinkels |
I don't know if you noticed but the -nolisten tcp option sounds like X won't be listening to anything you want to send it through network, even if it's from localhost.
|
you would need to read the man page of xhost..http://www.manpagez.com/man/1/xhost/.
xhost +localhost will allow to connect from console or from another x session on the localhost but only for the same user. xhost +root will allow the user root to connect. xhost + will completely switch off access control, so anyone can connect from anywhere. |
I just tried adding xhost +localhost on my computer (runs with -nolisten tcp) and just got kicked out of trying to run one application from a VT (as I expected, as a matter of fact).
|
Quote:
- I know I am able to connect from other hosts over ssh, using ssh -x, which means there connection possible from the localhost. (I believe ssh -x acts like a tunnel) - Turning off -nolisten in Debian is one of the best kept secrets in the X environment. Googling yields hundreds of solutions telling (a) to switch this off in /etc/X11/xinit/xserverrc, but this file and directory doesn't exist or (b) grep in /etc/ and subfolders for the string nolisten, which is not found. Ref. the second paragraph, I would be extremely happy if someone can tell me how to switch off this option so I can experiment with it. It is not funny to see how numerous parrot posters on forums simply repeat (verbatim): "you have to turn off this option by editing xserverrc". jlinkels |
Quote:
Quote:
Quote:
jlinkels |
Quote:
|
Quote:
Regards |
Quote:
Frankly I despise the Xorg/KDM/KDE policy to hide, move, rename or obsolete configuration files. If the config files are still present and being used they can be in 17 different locations, and on top of that Debian applies its own policy of using or ignoring files. Xorg/KDM/KDE is not the easiest by nature alone, and we could do without additional obfuscation. jlinkels OT1: Love to see that configuration in the post you are referring to. I used to sell those machines in 1998 with Win98 installed. Yikes! OT2: Your statement about Facebook could not be more true! Someday I would expect Facebook to collect all information about my machine, web pages I have visited and whatnot, and then add me to a community: "Hi jlinkels: we thought you might like to know that all these people have visited amazon.com like you did, so we added you to that group. You will receive all mail from those group members, and we carefully have hidden the unsubscribe button" |
Quote:
jlinkels |
All times are GMT -5. The time now is 03:49 PM. |