Created
November 19, 2015 18:01
-
-
Save UVClay/abb86ba3d5da04b838de to your computer and use it in GitHub Desktop.
OS X Screenshot Upload Utility
This file contains hidden or 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
#!/bin/bash | |
# OS X Screenshot Automation | |
# github.com/uvclay/osx-ss | |
# Alpha whatever it works so who cares | |
# Requires: fswatch, terminal-notifier | |
# TODO: Installer | |
# TODO: Notification area icon | |
# TODO: launchctl daemon | |
# TODO: Rewrite awful bash loop in Python | |
while : | |
do | |
fswatch -o ~/Screenshots/Temp | xargs -n1 ~/Screenshots/Script/manage.py | |
done |
This file contains hidden or 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
# OS X Screenshot Automation | |
# github.com/uvclay/osx-ss | |
# Alpha whatever it works so who cares | |
# Requires: fswatch, terminal-notifier | |
# TODO: Installer | |
# TODO: Notification area icon | |
# TODO: launchctl daemon | |
# TODO: Rewrite awful bash loop in Python | |
import configparser | |
import os | |
import random | |
import string | |
import subprocess | |
from ftplib import FTP | |
from glob import glob | |
config = configparser.ConfigParser() | |
config.read('ss.ini') | |
def main(): | |
new = gen()+'.png' | |
os.chdir(config['main']['TempDir']) | |
files = glob('*.png') | |
for file in files: | |
os.rename(file, '../'+new) | |
ftp = FTP(config['main']['FTPHost'], config['main']['FTPUser'], config['main']['FTPPass']) | |
img = open('../'+new, "rb") | |
print('up to opening img') | |
ftp.storbinary('STOR '+new, img) | |
url = "http://i.clay.coffee/"+new | |
print('uploaded') | |
img.close() | |
subprocess.Popen(['terminal-notifier', '-title', 'Screenshot Uploaded!', '-message', 'Image uploaded to: '+url+'', '-open', url, '-sound', 'default']) | |
ftp.quit() | |
def gen(size=5, chars=string.ascii_letters + string.digits): | |
# http://stackoverflow.com/a/2257449 | |
return ''.join(random.choice(chars) for _ in range(size)) | |
# TODO: Rework to support other file types (too lazy right now) | |
if __name__ == "__main__": | |
main() |
This file contains hidden or 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
[main] | |
FTPHost = | |
FTPUser = | |
FTPPass = | |
TempDir = /Users/clay/Screenshots/Temp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment