Contexts¶
LibInput¶
-
class
libinput.
LibInput
(context_type=<ContextType.PATH: 1>, debug=False)¶ A base/factory class for libinput context.
Context is used to manage devices and get events.
-
__init__
(context_type=<ContextType.PATH: 1>, debug=False)¶ Initialize context.
Parameters: - context_type (ContextType) – If
UDEV
devices are added/removed from udev seat. IfPATH
devices have to be added/removed manually. - debug (bool) – If false, only errors are printed.
- context_type (ContextType) – If
-
log_handler
¶ Callable that handles error/info/debug messages.
Parameters: - priority (LogPriority) – Message priority.
- message (str) – The message.
Default handler prints messages to stdout.
-
suspend
()¶ Suspend monitoring for new devices and close existing devices.
This all but terminates libinput but does keep the context valid to be resumed with
resume()
.
-
resume
()¶ Resume a suspended libinput context.
This re-enables device monitoring and adds existing devices.
-
LibInputPath¶
-
class
libinput.
LibInputPath
(*args, **kwargs)¶ libinput path context.
For a context of this type, devices have to be added/removed manually with
add_device()
andremove_device()
respectively.-
add_device
(path)¶ Add a device to a libinput context.
If successful, the device will be added to the internal list and re-opened on
resume()
. The device can be removed withremove_device()
. If the device was successfully initialized, it is returned.Parameters: path (str) – Path to an input device. Returns: A device object or None
.Return type: Device
-
remove_device
(device)¶ Remove a device from a libinput context.
Events already processed from this input device are kept in the queue, the
DEVICE_REMOVED
event marks the end of events for this device.If no matching device exists, this method does nothing.
Parameters: Device (Device) – A previously added device.
-
LibInputUdev¶
-
class
libinput.
LibInputUdev
(*args, **kwargs)¶ libinput udev context.
For a context of this type, devices are added/removed automatically from the assigned seat.
-
assign_seat
(seat)¶ Assign a seat to this libinput context.
New devices or the removal of existing devices will appear as events when iterating over
get_event()
.assign_seat()
succeeds even if no input devices are currently available on this seat, or if devices are available but fail to open. Devices that do not have the minimum capabilities to be recognized as pointer, keyboard or touch device are ignored. Such devices and those that failed to open are ignored until the next call toresume()
.Warning
This method may only be called once per context.
Parameters: seat (str) – A seat identifier.
-