Emulating Adobe Reader's Snapshot tool in Ubuntu



In this post I presented a simple python script for copying image files to the gnome clipboard. In this post, I'll show how I use this script with imageMagik to emulate the snapshot tool in Adobe Reader. I originally wanted to use this just for Evince (default Ubuntu document reader) but have found all kinds of situations where it's handy outside of Evince.

The end goal here is to have a key binding which, when pressed, starts a "selection mode" where any part of the screen can be selected. That selection is then copied to the gnome clipboard so that it can be pasted into a document (i.e. a libreoffice or openoffice document, though I usually use it to paste into Xournal).

The script

Here is the script I use to do just that.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#!/bin/bash

#prefix for filename
prefix='screenshot';
timestamp=`date '+%d-%m-%y-%N'`;
extension='.png';

file="/tmp/$prefix-$timestamp$extension";

import $file
python $HOME/Codes/python/imgclip/imgclip.py $file

The import tool is part of the imageMagik package. It does the screenshot taking part, by changing the mouse cursor to a "selection" tool. It saves the screenshot in /tmp/screenshot_TIMESTAMP.png where the timestamp is generated by the date command. The script then runs imgclip to copy the screenshot to the clipboard. I have this script bound to a command in compiz. The command is

bash $HOME/Codes/shell/screenshot/screenshot.sh

Here is a screencast of it in action:

Comments


Comments powered by Disqus