snegg.oeffis module
Wrapper module around the liboeffis
C library. This is a thin API wrapper with
most of the semantics of the underlying C library preserved.
See the liboeffis documentation
for details on each API.
Warning
Most objects in this module are refcounted and automatically destroy the underlying C object when the Python reference is dropped. This may cause all sub-objects in the underlying C object to be destroyed as well. Care must be taken to preserve the Python object across multiple invocations.
- class snegg.oeffis.DeviceType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
IntFlag
The set of devices to request from the RemoteDesktop session.
- ALL_DEVICES = 0
- KEYBOARD = 1
- POINTER = 2
- TOUCHSCREEN = 4
- exception snegg.oeffis.DisconnectedError(message)
Bases:
Exception
Raised when our context is disconnected from the bus. This error is raised when the connection encountered some error, e.g. a misconfiguration or access errors.
See
SessionClosedError
for the exception raised when our session was explicitly closed.- message
A message to indicate the cause of the disconnection.
- class snegg.oeffis.Oeffis
Bases:
object
Wrapper class around a liboeffis context. See the liboeffis documentation for oeffis_new() for details: https://libinput.pages.freedesktop.org/libei/api/group_liboeffis.html
This is a Pythonic wrapper, after creating a session use the fd property to monitor for events and call dispatch() in response to any events on that file descriptor.
Note that the
Oeffis
context must be kept alive for the duration of the session, destroying the context results in disconnection and thus the EIS fd becoming invalid for any libei contexts that use that fd.- classmethod create(devices: int = DeviceType.ALL_DEVICES, busname: str = 'org.freedesktop.portal.Desktop') Oeffis
Create a liboeffis context for the given set of devices on the given busname.
- dispatch() bool
Dispatch any pending events and return
True
if we are connected, orFalse
if there’s nothing happening right now.If we get disconnected and/or the session is closed, this function raises a
DisconnectedError
orSessionClosedError
, respectively. Calling dispatch after getting disconnected/closed will result in the same exceptions being thrown.
- property eis_fd: int
The file descriptor to pass to
snegg.ei.Sender.create_for_fd
. This file descriptor does not exist untildispatch()
returnsTrue
.Warning
Reading this property descriptor raises a
DisconnectedError
if invoked beforedispatch()
returnsTrue
- property error_message: Optional[str]
Returns the error message that caused this context to disconnect. In most cases this is the same error that was already raised in the
DisconnectedError
exception.This method returns None if our context is still connected.
- property fd: IO
The file descriptor to monitor for incoming events. Whenever an event occurs on this file descriptor, call
dispatch()
immediately to process the events.
- exception snegg.oeffis.SessionClosedError
Bases:
DisconnectedError
Raised when our session was closed by the XDG Desktop Portal. This may happen in response to some user interaction but is not typically an indication of an error. See
DisconnectedError
for the exception raised when an error occurs.