Python Xlib - Xlib.error.BadAccess on root.display.next_event ()

Hi, I just started Python, and I decided to make a program that catches certain keys, I found an online source that grabs mouseclicks and decided to start with this, this is the code:

import Xlib import Xlib.display display = Xlib.display.Display(':0') root = display.screen().root root.change_attributes(event_mask = Xlib.X.ButtonPressMask | Xlib.X.ButtonReleaseMask) while True: event = root.display.next_event() print "hi" 

This is an error when I run it:

 miles@miles :~/py/keynotify$ python x.py Xlib.protocol.request.QueryExtension X protocol error: <class 'Xlib.error.BadAccess'>: code = 10, resource_id = 173, sequence_number = 9, major_opcode = 2, minor_opcode = 0 ^CTraceback (most recent call last): File "x.py", line 9, in <module> event = root.display.next_event() File "/usr/lib/pymodules/python2.7/Xlib/protocol/display.py", line 171, in next_event self.send_and_recv(event = 1) File "/usr/lib/pymodules/python2.7/Xlib/protocol/display.py", line 502, in send_and_recv rs, ws, es = select.select([self.socket], writeset, [], timeout) KeyboardInterrupt 

Understand any help!

+4
source share

Source: https://habr.com/ru/post/1436211/


All Articles