Commits

Anonymous committed 5aa1046

feed clipboard

Comments (0)

Files changed (1)

 # -*- coding: utf-8 -*-
 
 import os
-from subprocess import Popen
+from subprocess import Popen, PIPE
 from tempfile import NamedTemporaryFile
 
+def feed_xclipboard(str):
+    pipe = Popen("xclip -sel clip", shell=True, stdin=PIPE).stdin
+    pipe.write(str)
+    pipe.close()
 
-if __name__ == '__main__':
+def import_screenshot():
     filename = NamedTemporaryFile(
         suffix='.png',
         prefix='screenshot_',
         delete=False).name
     p = Popen("/usr/bin/import " + filename, shell=True)
     sts = os.waitpid(p.pid, 0)[1]
+    return filename
+
+
+if __name__ == '__main__':
+    screenshot = import_screenshot()
+    feed_xclipboard(screenshot)