Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions config.cfg-sample-linux
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions config.cfg-sample-mac
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 10 additions & 3 deletions screenshot
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand All @@ -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())
Expand All @@ -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)

Expand Down