"socket.error: [Errno 111] Connection refused" when attempting to monitor ACPI event in Python

1.1k Views Asked by At

I am attempting to monitor ACPI events in order to detect when the screen on a ThinkPad S1 Yoga has been folded over (turning a laptop into a tablet). What I'm watching for is the following, which indicates that the screen position has been toggled:

sudo acpi_listen
ibm/hotkey HKEY 00000080 000060c0

I'm very new to this, but following online instructions and code, I am attempting to monitor ACPI events in Python using the module socket, but I'm running into difficulties:

>>> import socket
>>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
>>> s.connect("/var/run/acpid.socket")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused

I would appreciate some guidance. Thanks!

0

There are 0 best solutions below