Last active
November 1, 2022 15:31
-
-
Save grahams/85e80ab7a59ad5cfd0250397aa4eebd1 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
import sys | |
import os | |
import subprocess | |
from datetime import date | |
import random | |
import string | |
import pathlib | |
year = str(date.today().year) | |
def setClipboardData(data): | |
p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE) | |
p.stdin.write(bytes(data, "utf8")) | |
p.stdin.close() | |
retcode = p.wait() | |
return retcode | |
for f in sys.argv[1:]: | |
if((f.find("Screenshot " + year) != -1) or (f.find("Screen Shot " + year) != -1)): | |
ext = pathlib.Path(f).suffix | |
rName = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.ascii_lowercase) for _ in range(6)) | |
destDir = "/Users/grahams/Resilio Sync/Public/Screenshots/" | |
destName = destDir + rName + ext | |
os.rename(f, destName) | |
setClipboardData("http://grahams.wtf/public/Screenshots/" + rName + ext) | |
cmd = 'osascript -e \'display notification "Screenshot uploaded: \' + rName + ext" with title "Resilio Screenshot Processor"\'' | |
subprocess.Popen(cmd, shell=True) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I created a Resilio Sync share that is on my desktop as well as a machine running a public web server. When I add files to the share from my local machine, it's mirrored into that public web space. I did this to replicate the Dropbox "Public" folder functionality.
Use this script from a Automator folder action on your ~/Desktop folder. As you use the standard OSX screenshot mechanism, this will trigger the script which will move it to the Resilio public folder and give it a pseudorandom filename.