wayland.client ¤
Functions:
-
is_wayland
–Check if the current session is running under Wayland.
-
start_debug_server
–Enable the Wayland protocol debugging service.
is_wayland ¤
is_wayland() -> bool
Check if the current session is running under Wayland.
Determines if the current environment is using Wayland by checking the WAYLAND_DISPLAY and XDG_SESSION_TYPE environment variables.
Returns:
-
bool
–True if running under Wayland, False otherwise.
Examples:
When running Wayland:
>>> import wayland
>>> wayland.client.is_wayland()
True
register_factory ¤
register_factory(interface_name: str, custom_class: type[WaylandObject])
Register a custom class to be used anytime Wayland objects of a specific interface are created.
Whenever any instance of the given Wayland interface is created an instance of the registered custom class will be created in place of the default class.
See also the decorator @wayland_class
, which provides another way to register custom classes.
Parameters:
-
interface_name
¤str
) –The wayland interface name (e.g., 'wl_registry')
-
custom_class
¤type[WaylandObject]
) –The custom class to use for this interface
Usage
wayland.register_factory('wl_registry', MyRegistry)
start_debug_server ¤
start_debug_server() -> str
Enable the Wayland protocol debugging service.
You can debug the requests and events between your application and the Wayland compositor easily using the debugger included with python-wayland
.
Simply enable debugging in your application and then use the stand-alone debugger to monitor Wayland messages as your application is running.
Step 1: To enable protocol debugging in your application call start_debug_server
. This call returns immediately.
wayland.client.start_debug_server()
Step 2: Run your application and then start the protocol debugger:
python -m wayland.client.debug
This will start the terminal protocol debugger:
You could also connect to your application directly using the file socket that start_debug_server
opened with a utility such as socat
:
socat - ABSTRACT-CONNECT:python-wayland-debug
Returns:
-
str
–The name of the abstract file socket on which the server is listening.
wayland_class ¤
A decorator to register a custom class to be used anytime Wayland objects of a specific interface are created.
Whenever any instance of the given Wayland interface is created an instance of the registered custom class will be created in place of the default class.
Examples:
Register our own class MyRegistry
to be instantiated whenever a wl_registry
object is created:
@wayland_class("wl_registry")
class MyRegistry(wayland.wl_registry): ...
See also register_factory
for an explicit method of class registration.