Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I was wondering if there is a way to automatically add a given meta-tag to the screen-shots taken on pressing print screen key.

It would really be a time-saver because I upload many screen-shots to my blog regularly. It will avert the need of adding tags manually to all screen-shots.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You could map the keyboard shortcut of your choice to a (very) short script that goes something like:

#!/bin/sh
FILENAME=~/screenshot.jpg
TAGSTRING="tag:screenshot"
KW="My keyword"

activeWinLine=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)")
activeWinId=${activeWinLine:40}
import -window "$activeWinId" $FILENAME -comment $TAGSTRING

# More advanced exif info:
exiftool -keywords=$KW $FILENAME

To make this executable, save it as something like myscreenshot and then do

chmod u+x myscreenshot

Placing it in your ~/bin/ directory and making sure that that is in your path means it will be executable from whatever directory it is called from.

Then depending on your desktop environment you need to map whatever keyboard shortcut you like to the command myscreenshot.

for example in Gnome, select keyboard shortcuts from preferences, and assign a custom shortcut (you decide on the key combination) to the command myscreenshot. If you didn't put the executable in a path on the PATH, then you would have to specify the full path in the command argument, such as '/home/USER/bin/./myscreenshot'

NOTE

This takes a screenshot of the active window but can be easily modified to take a screenshot of the whole window if that's what you want.

exiftool

exiftool may also do what you want - perhaps giving more flexibility over the information to store than the comment string alone.

For example

exiftool -keywords=one -keywords=two -keywords=twentythree FILENAME

will add the keywords one, two, and three to FILENAME.

GUI alternative

Also TAGSTRING can either be set in the script file, or perhaps passed in using a simple zenity dialog, depending on if it will be the same each time or you need to be able to change it.

Alternatively, shutter seems to have a lot of customization options (many more than the stock screen capture tool), including upload! See here for more information.

share|improve this answer
    
Can you elaborate on any one method? I think script will be very convenient. But I do not know how to map it to a keyboard short cut. By the way, I do not want screen-shot of the active window. I want to select an area. –  Chirag Jul 25 '12 at 21:57
    
The mapping is independent of the script itself and depends on which desktop environment you're using. First though you have to make the script executable and declare the relevant variables - I've edited the post to reflect this. –  mutzmatron Jul 25 '12 at 21:58
    
It's not writing anything when I see properties. Nothing under comments. Weird. –  Chirag Jul 25 '12 at 23:01
    
So you're getting the screenshot ok without comments or tags, is that correct? –  mutzmatron Jul 25 '12 at 23:05
    
Exactly. That's right. –  Chirag Jul 25 '12 at 23:24
show 6 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.