diff --git a/README.md b/README.md index 09d649d..67926d2 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,13 @@ possibly. To use GtkGrab in gif mode, simply invoke it with `./screenshot gif`. +## Keeping a local copy + +You might want to keep a local copy of your screenshot! If you do, just add +the configuration option `localCopyPath` with where you want to store your +saved screenshots. The screenshots will be named with date and time. The path +does NOT need a trailing slash. + ## Troubleshooting * P: After taking a screenshot no notification is displayed, when running it diff --git a/config.cfg-sample-linux b/config.cfg-sample-linux index 3d8e89f..13e5e11 100644 --- a/config.cfg-sample-linux +++ b/config.cfg-sample-linux @@ -6,3 +6,5 @@ command=scrot --b -s %s gifCommand=record-gif.sh $(zenity --entry --text="How long to record?") %s notifyCommand=notify-send --hint=int:transient:1 "Screenshot Uploaded" "Copied URL to clipboard:\n %s" capPath=/tmp/ss.png +# Note: path must exist +# localCopyPath=/home/user/Pictures/Screenshots diff --git a/config.cfg-sample-mac b/config.cfg-sample-mac index cbce99c..367073c 100644 --- a/config.cfg-sample-mac +++ b/config.cfg-sample-mac @@ -5,3 +5,5 @@ posturl=http://yourhost.tld/gtkgrab/handler.php command=screencapture -i %s notifyCommand=/usr/local/bin/growlnotify -m "Copied url to clipboard: %s" -n "GtkGrab" capPath=/tmp/ss.png +# Note: path must exist +# localCopyPath=/Users/user/Pictures/Screenshots diff --git a/screenshot b/screenshot index efb408e..de961c2 100755 --- a/screenshot +++ b/screenshot @@ -20,6 +20,8 @@ # @package Client import ConfigParser, sys, urllib2, os, base64, hashlib, pyperclip, time +from datetime import datetime +from shutil import copyfile config = ConfigParser.ConfigParser() config.readfp(open(os.path.dirname(sys.argv[0]) + '/config.cfg')) @@ -43,14 +45,14 @@ if postURL == 's3': prefix = config.get('GtkGrab', 's3prefix') filename = hashlib.sha1() filename.update(str(time.time())) - filename = filename.hexdigest() - s3Url = "s3://" + bucket + "/" + prefix + "/" + filename + ".png" + filename = filename.hexdigest()[:7] + s3Url = "s3://" + bucket + "/" + filename + ".png" uploadCommand = "s3cmd "; if (os.path.exists('.s3cfg')): uploadCommand += "-c .s3cfg " uploadCommand += "put " + path + " " + s3Url + " --acl-public" os.system(uploadCommand) - url = "http://"+bucket+".s3.amazonaws.com/caps/"+filename+".png" + url = "http://"+bucket+".s3.amazonaws.com/"+filename+".png" else: # encode the screenshot with base64 data = base64.b64encode(open(path, 'r').read()) @@ -62,6 +64,11 @@ else: # upload the url and give the screenshot url to the user url = urllib2.urlopen(urllib2.Request(postURL, data, headers)).read() +if config.has_option('GtkGrab', 'localCopyPath'): + now = datetime.now() + localCopyFile = config.get('GtkGrab', 'localCopyPath') + '/Screenshot from ' + now.strftime('%Y-%m-%d %H-%M-%S') + '.png' + copyfile(path, localCopyFile) + # remove the file os.remove(path)