Skip to content

Instantly share code, notes, and snippets.

@subtosilencio
Created August 12, 2020 14:17
Show Gist options
  • Save subtosilencio/c82bf5a50a14c7731e82a6b6ed904ab2 to your computer and use it in GitHub Desktop.
Save subtosilencio/c82bf5a50a14c7731e82a6b6ed904ab2 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
# Linux Ubuntu Gnome
# Correction for Pyperclip
# Copy info to clipboard without installing anything
from gi.repository import Gtk, Gdk
def copy_to_clipboard(msg):
''' Copy `msg` to the clipboard '''
cb = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
cb.set_text(msg,-1)
cb.store()
def paste_from_clipboard():
''' Paste last info from clipboard '''
cb = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
return cb.wait_for_text()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment