Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gnome shell extension, copy text to clipboard

I'm working on a Gnome Shell Extensions and I can't find any documentation on how to copy some string into the clipboard for the user.

I searched the Gnome extensions git but without any success.

Thank you for your help! :)

like image 709
Cyril N. Avatar asked Feb 22 '23 03:02

Cyril N.


1 Answers

to set the primary clipboard:

St.Clipboard.get_default().set_text(St.ClipboardType.PRIMARY, 'text');

to get the primary clipboard:

St.Clipboard.get_default().get_text(St.ClipboardType.PRIMARY);

There also is the St.ClipboardType.CLIPBOARD buffer.

(source code)

like image 83
Omid Avatar answered Feb 23 '23 17:02

Omid