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
Trending Categories
95
Software18
DevOps35
Frontend Development19
Backend Development17
Server Administration13
Linux Administration16
Data Center20
Sentry22
Terraform19
Ansible19
Docker19
Penetration Testing12
Kubernetes13
NGINX14
JenkinsX16
Jenkins20
SSL10
Ethical-Hacking10
Python12
NodeJs15
RedHat14
Github18
AngularJs15
Google Cloud Platform (GCP)6
SonarQube13
Amazon Web Service (AWS)13
VMware17
Blockchain12
Snipe-IT7