clipboard API for the autokey-gtk application on X11

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 Gtk implementation.

class autokey.scripting.clipboard_gtk.GtkClipboard(app=None)[source]

Read/write access to the X selection and clipboard - GTK version

fill_clipboard(contents)[source]

Copy text into the clipboard

Usage: clipboard.fill_clipboard(contents)

Parameters:

contents – string to be placed in the selection

fill_selection(contents)[source]

Copy contents into the X 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 X selection refers to the currently highlighted text.

Usage: clipboard.get_selection()

Returns:

text contents of the mouse selection

Return type:

str

set_clipboard_image(path)[source]

Set clipboard to image

Usage: clipboard.set_clipboard_image(path)

Parameters:

path – Path to image file

Raises:

OSError – If path does not exist