Screenshot + Upload with one keypress
I wanted to share a screenshot with somebody online the otherday, but the routine that came to mind went like this ..
- Load the gimp
- Click several buttons
- Switch to the desktop I want to screenshot
- Save the image to disk
- Copy the image to my web server
- Test the URL
- .. and finally pasting the URL to the person
So, I searched aptitude for an alternative
apt-cache search screenshot | grep screen
and shutter was able to eliminate a few of the above steps, but I thought that at some point I should stop being lazy and write a script.
My script will:
- Take a screenshot with a generated filename
- Upload the screenshot to my webserver
- Copy the URL for the screenshot to the clipboard
- Be bound to a keyboard shortcut in awesome
So that when I want to share a screen with somebody I only have to press a button, wait a few seconds then paste the URL.
My script
#/bin/bash
FNAME=`uname -n`-`date +%Y%m%d%H%M%S`.png
SSH=daniel@www.dantleech.com:/home/daniel/screenshots
URL=http://www.dantleech.com/screenshots/
import -window root /tmp/$FNAME
scp /tmp/$FNAME $SSH
rm /tmp/$FNAME
echo $URL$FNAME | xclip -i -selection primary
So it:
- Defines some configuration variables
- Takes the screenshot using import
- Copies the screenshot to the server using scp
- Removes the temporary file
- Pipes the URL into the X clipboard using xclip
Integrating it into the Awesome WM
I added a keybinding in the rc.lua configuration file which calls the following function:
function screenshot()
os.execute("/home/daniel/scripts/screenshot.sh")
naughty.notify({title = "Screenshot taken"
, text = "URL copied to clipboard"
, timeout = 5
, position = "top_right"
, fg = beautiful.fg_focus
, bg = beautiful.bg_focus
})
end
So it will execute my script and, when it has finished, awesome will notify me with a little popup in the top-right hand corner. Pretty neat I think!

Example showing scripts
Comments
Post new comment
Tags
- DropBox
- XMPP
- android
- apache
- archos
- audacious
- awesome
- bash
- bootstrap
- bristol
- diagramming
- doctrine
- doctrine2
- git
- gloucester
- graphs
- gt540
- jack
- javascript
- manchester
- mapdroyd
- markdown
- mongodb
- paris
- php
- profiling
- projectm
- running
- scripting
- sed
- software design
- ssh
- symfony
- symfony2
- thonon-les-bains
- trainer
- travel
- twig
- ubnutu
- vim
- weymouth
- workflow
- xdebug
- xml
- ylly
- yprox
10 Latest Items
-
08
Maytrainer [Velo] paris - compiègne 153.00km / 05:48:32 / 00:02:16mpkm Fois.
-
06
Maytrainer [Velo] Vincennes Hippodrome 1hr 34.34km / 01:00:00 / 00:01:44mpkm Solo effort. Did interfals (sprinting from zebra crossing to hairpin turn).
-
05
Maytrainer [Run] Diderot > Pnt. Alx III > Rue de Charonne 13.96km / 01:08:40 / 00:04:55mpkm Good to run in the rain. Lots of traffic.
-
04
Maytrainer [Velo] Vincennes Hippodrome 1hr 32.20km / 01:00:00 / 00:01:51mpkm Rode apace a peloton, but tried not to get in the draft. Sprinted for a few minutes on every lap.
-
03
Maytrainer [Run] Dumas > P. Auguste > Belleville > Prc. de Villette > Pt. de Lilas > Pt. Vincennces 14.48km / 01:07:00 / 00:04:37mpkm Kept up a reasonably good pace. No problems from calf muscle as was the case yesterday.
-
02
Maytrainer [Run] Dumas > Diderot > Trocadero > Basitlle 14.48km / 01:10:00 / 00:04:49mpkm Experienced pain in the back of my calf and stopped a few times towards the end.
-
01
Maytrainer [Velo] Dumas > Rambouillet 123.31km / 05:06:00 / 00:02:28mpkm Paris Rambouillet. Sunny day. Ate a bakery pizza, tarte au pomme and drank a cola then lay down on a bench in the châte...
-
29
Aprtrainer [Run] 14 - 15 miles 23.34km / 01:50:00 / 00:04:42mpkm Run down the Rue Charonne, down Boulevard Henri IV, round le Ile St-Louis, along the Seine, crossing the Pont d'lén...
-
28
Aprtrainer [Velo] Vincennes Hippodrome 1hr 34.12km / 01:00:00 / 00:01:45mpkm Actually 45 minutes. Rain stopped play. Also boredom. "Sprinted" up the second half of the upside at each circ...
-
27
Aprtrainer [Run] 54 minutes 11.50km / 00:54:00 / 00:04:41mpkm Ran down and around.
