Skip to content

Instantly share code, notes, and snippets.

@Leo7654
Last active October 28, 2020 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Leo7654/477cb8b12982438dc199491253219ff4 to your computer and use it in GitHub Desktop.
Save Leo7654/477cb8b12982438dc199491253219ff4 to your computer and use it in GitHub Desktop.
[OSX] Copy Screenshots to clipboard
  1. Change folder for screenshot.
defaults write com.apple.screencapture location ~/screens/
killall SystemUIServer
  1. Copy ss2cb.plist to ~/Library/LaunchAgents/.
  2. Copy ss2cb.py to ~/.
  3. Test with Cmd + Shift + 4 & Paste it!
  4. Done!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>StandardErrorPath</key>
<string>/tmp/ss2cb.err</string>
<key>StandardOutPath</key>
<string>/tmp/ss2cb.log</string>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>copy Screen Shots to ClipBoard</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/python</string>
<string>~/ss2cb.py</string>
</array>
<key>WatchPaths</key>
<array>
<string>~/screens/</string>
</array>
</dict>
</plist>
#! /usr/bin/python
import pygtk
pygtk.require('2.0')
import gtk
import os
import sys
def copy_image(f):
assert os.path.exists(f), "file does not exist"
image = gtk.gdk.pixbuf_new_from_file(f)
clipboard = gtk.clipboard_get()
clipboard.set_image(image)
clipboard.store()
def all_files_under(path):
path = os.path.expanduser(path);
cur_path = path
for filename in os.listdir(path):
yield os.path.join(cur_path, filename)
if len(sys.argv) < 2:
file = max(all_files_under('~/screens/'), key=os.path.getctime)
else:
file = sys.argv[1]
copy_image(file);
print 'File: "' + file + '" Copied'
@Leo7654
Copy link
Author

Leo7654 commented Jan 21, 2019

Turn Off Mojave Screenshot Previews
defaults write com.apple.screencapture show-thumbnail -bool TRUE

@Leo7654
Copy link
Author

Leo7654 commented Jan 21, 2019

Load: $ launchctl load -w ~/Library/LaunchAgents/ss2cb.plist
Log: $ tail -f /var/log/system.log
Log: $ tail -f /tmp/ss2cb.*

@Leo7654
Copy link
Author

Leo7654 commented Oct 26, 2020

ImportError: dlopen(/usr/local/lib/python2.7/site-packages/glib/_glib.so, 2): Library not loaded: /usr/local/opt/libffi/lib/libffi.6.dylib
-->
platformio/platform-lattice_ice40#7

@Leo7654
Copy link
Author

Leo7654 commented Oct 28, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment