clipboard API for Wayland environments

This class is invoked as the “clipboard” class in AutoKey scripts. For example, the “autokey.scripting.clipboard_gtk.GtkClipboard.fill_clipboard()” method documented below is called as “clipboard.fill_clipboard()” in an AutoKey script.

There are three different implementations of the “clipboard” class, one for Wayland environments, one for X11/Gtk, and one for X11/Qt. They all offer the exact same methods. This the Wayland implementation.

class autokey.scripting.clipboard_wayland.WaylandClipboard(app=None)[source]

Read write access to the Wayland desktop using the wl-clipboard utility

fill_clipboard(contents: str)[source]

Copy text into the clipboard

Usage: clipboard.fill_clipboard(contents)

Parameters:

contents – string to be placed in the selection

fill_selection(contents: str)[source]

Copy text into the selection

Usage: clipboard.fill_selection(contents)

Parameters:

contents – string to be placed in the selection

get_clipboard()[source]

Read text from the clipboard

Usage: clipboard.get_clipboard()

Returns:

text contents of the clipboard

Return type:

str, or bytearray on Python >= 3.13

get_selection()[source]

Read text from the X selection The selection refers to the currently highlighted text.

Notice: This is not possible under Wayland.

Usage: clipboard.get_selection()

Returns:

text contents of the mouse selection

Return type:

str

set_clipboard_image(path: str)[source]

Set clipboard to image

Usage: clipboard.set_clipboard_image(path)

Parameters:

path – Path to image file

Raises:

OSError – If path does not exist