Error: Couldn't open display (null)

885 views
Skip to first unread message

Suto Attila

unread,
Jul 27, 2011, 10:43:56 AM7/27/11
to xdotool-users
Hi all, I wrote a program in C using xdotool. The program gets the
active window properties(title, class, etc). I need to run this in
Ubuntu at startup in background and I wrote a script to start the
program. If i run the script after startup, it's running well, but at
startup fails with "Error: Couldn't open display (null) ". The error
is from where the program calls XInternAtom function. I tried to put
the script in /etc/init.d/ and /etc/X11/Xsession.d/, but it fails in
both cases.

char* get_window_prop(unsigned char** title, unsigned char**
machine...)
{
xdo_t* xdo=xdo_new(NULL);
Atom atom= XInternAtom(xdo->xdpy,"WM_NAME",True);
.......

Can somebody tell me how to make this work at startup?
Thank you

Jordan Sissel

unread,
Jul 27, 2011, 1:09:24 PM7/27/11
to suto...@gmail.com, xdotool-users

"Can't open display (NULL)" means that libxdo tried to contact the X11 server, but it couldn't - since you say it fails "during startup" that's probably because it runs before there is an X server running.

I don't pretend to know how or what ubuntu does during X11 startup; you are best off trying to find a way to tell your window manager to run the program at login. How you do that will vary wildly depending on what window manager you are using.

-Jordan


--
You received this message because you are subscribed to the Google Groups "xdotool-users" group.
To post to this group, send email to xdotoo...@googlegroups.com.
To unsubscribe from this group, send email to xdotool-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xdotool-users?hl=en.


Suto Attila

unread,
Jul 28, 2011, 2:17:01 AM7/28/11
to xdotool-users
I figured out that if I put my script in the /etc/X11/Xsession.d/
folder it's running after log in. Thank you for the answer, problem
solved.
Reply all
Reply to author
Forward
0 new messages