Created
December 8, 2022 09:46
-
-
Save MrYakobo/096ab9ba0ba4da19a318feeb242bedc8 to your computer and use it in GitHub Desktop.
xclip and xsel alternative, for non-epel rpm distros for example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# takes text on stdin and stores it in the clipboard | |
# depends on gtk (i.e. a gnome desktop or something alike) | |
import gi | |
gi.require_version('Gtk', '3.0') | |
from gi.repository import Gtk, Gdk | |
import fileinput | |
text = "".join(fileinput.input()).rstrip('\n') | |
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) | |
clipboard.set_text(text, -1) | |
clipboard.store() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment