Techiio-author
Started by Bruce MccullamSep 29, 2021

Open
How can I put text in the clipboard using Gnu/Linux and Python?

0 VIEWES 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWES SHARE

I have a Python TUI application and I want it to save the the result of a user selection.

It's pretty easy to find a windows and mac api to copy something to the user clipboard, but how to do so in Linux from Python?

It needs to:

  • work accross DE: at least gnome shell and kde.
  • work on x and wayland.
  • work without installing a third party package from the linux repo (such as xclip) since you can't pip install xclip. This means the pypi clipboard package is excluded since it relies on that.
  • it works without loading a GUI widget that requires the user to select the content, since the copy may happen in the background or in a TUI. The text may not be selected with the mouse.

xclip does it for xwindows, so there muse be an api for that. And DE for wayland allow it, so there must be some c code I can call using ctypes maybe.

0 Replies

You must be Logged in to reply
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance