RuntimeError: could not open display

238 views
Skip to first unread message

JDA

unread,
Dec 18, 2009, 2:35:10 PM12/18/09
to autokey-users
Hi,

I'm hoping someone can help me in trying to run AutoKey on Fedora 10.
As suggested in another post in this group, I did the following:

As root...
1. Download and expand "autokey-gtk_0.61.1.tar.gz"
2. python setup.py install (didn't show any errors)
3. cp debian/autokey-gtk.init /etc/init.d/autokey
4. chmod a+x /etc/init.d/autokey
5. chkconfig --add autokey
6. service autokey start

The "service autokey start" command resulted in these messages:

Traceback (most recent call last):
File "/etc/init.d/autokey", line 16, in <module>
from autokey.interface import DOMAIN_SOCKET_PATH, PACKET_SIZE
File "/usr/lib/python2.5/site-packages/autokey/interface.py", line
38, in <module>
import gtk
File "/usr/lib/python2.5/site-packages/gtk-2.0/gtk/__init__.py",
line 79, in <module>
_init()
File "/usr/lib/python2.5/site-packages/gtk-2.0/gtk/__init__.py",
line 67, in _init
_gtk.init_check()
RuntimeError: could not open display

From a little searching on that message, I got the impression that it
might be related to the DISPLAY variable, which on my system is ":
0.0".

Can anyone give me a hint as to what the problem is, or what debugging
steps I should try next? By the way, my system does normally run an
older version of AutoKey (0.50.0), which is apparently of an older
architecture in that it doesn't use any "/etc/rc.d/init.d" mechanism
like the new one does. (And I did shut the old one down before trying
to start the new version.)

Thanks,

Jim

Chris Dekter

unread,
Dec 19, 2009, 1:52:42 AM12/19/09
to autoke...@googlegroups.com
Are you running the service command from a remote ssh terminal or a
console with no X server attached? That would cause this symptom.

2009/12/19 JDA <jim.a...@gmail.com>:

JDA

unread,
Dec 20, 2009, 9:03:15 AM12/20/09
to autokey-users
I am running these commands from an xterm window directly on the
machine. I can run commands such as xeyes or xclock with no
problems. Since my first post I have also tried this on a Fedora 11
system, with the same results. I don't know much about Python, but am
wondering if there's a way to turn on debug mode, so I could see what
exactly is failing.

Thanks.

On Dec 18, 11:52 pm, Chris Dekter <cdek...@gmail.com> wrote:
> Are you running the service command from a remote ssh terminal or a
> console with no X server attached? That would cause this symptom.
>

> 2009/12/19 JDA <jim.adam...@gmail.com>:

Derek

unread,
Dec 20, 2009, 9:45:59 AM12/20/09
to autokey-users
JDA,

Start AutoKey at the command line with this:

autokey -l

That's a lowercase L. That will show you the debug logging messages
while it runs.

Derek

JDA

unread,
Dec 21, 2009, 3:13:34 PM12/21/09
to autokey-users
I have solved this problem. I don't know how non-Fedora systems are
configured, but I tracked this problem down to the "/sbin/service"
command on my systems. The "service" command is a shell script that
uses a command beginning with "env -i ..." to invoke the given service
startup script from the /etc/rc.d/init.d directory. Well, the "-i"
option says to not inherit any environment variables from the caller
of the "service" command, which results in no DISPLAY variable being
set, and thus the inability to open the display.

So the fix for this was to modify the "/etc/rc.d/init.d/autokey"
startup script. Near the beginning of that script are these
statements:

import sys, os, socket, glob, shutil, time
from autokey import evdev, daemon


from autokey.interface import DOMAIN_SOCKET_PATH, PACKET_SIZE

I inserted an additional statement, so these statements now look like
this:

import sys, os, socket, glob, shutil, time
from autokey import evdev, daemon
os.environ["DISPLAY"]=":0.0"


from autokey.interface import DOMAIN_SOCKET_PATH, PACKET_SIZE

The new "os.environ" statement must precede the last statement.

There is probably a more elegant solution to this problem, but at
least this workaround gets AutoKey working.

Thanks for your help!

Jim

Reply all
Reply to author
Forward
0 new messages