3

Possible Duplicate:
Open a window on a remote X display (why “Cannot open display”)?

I have a script that when run independently works that needs X11 Display variables to be set. When I invoke this script using a background daemon job, I get the following error.
Xlib: connection to "localhost.localdomain:0.0" refused by server
Xlib: No protocol specified
Please help me identifying the possible mistake that I have in this.
Commands given below which is inside the script.
export DISPLAY=hostname:0.0
java ScreenCapture
If the same script is invoked by a background daemon running as a service, I get the error.

PackedUp
  • 151
  • 1
  • 2
  • 5

1 Answers1

3

I'm just guessing here, but the background daemon might be running as different user, which does not have permission to access the display.

You can use xhost to control user access:

The xhost program is used to add and delete host names or user names to the list allowed to make connections to the X server.

You can test if this is the problem by running:

xhost +

from a terminal window, which will allow any user to access the display.

xhost +(insert username here)

will allow access for a specific user.