#!/bin/bash # uwshot - the unix-way of making screenshots # Copyright (C) 2008 Roman Mamedov # # This program is free software: you can redistribute it and/or modify it under the terms of # the GNU General Public License version 3 as published by the Free Software Foundation. # See http://www.gnu.org/licenses/gpl-3.0.html for more details. # # Notable dependencies: # - scrot # - zenity # - pngcrush (optional) # # Usage: # uwshot.sh [baseurl] # # Parameters: # baseurl - the URL under which the current directory is accessible from the Web # # History: # 2010-04-14 - Updated to use UTC time and ISO 8601 date/time format # Added PID to the temporary file name # Updated to use "bash" instead of "sh" # 2008-08-26 - initial public release BASEURL=$1 TEMPNAME=`whoami`-uwshot-$$.tmp.png export TZ=UTC NAMEPREFIX=`date +%Y-%m-%dT%H%M%SZ-` # First, make a screenshot and pngcrush it sleep 1 scrot -f -b -s $TEMPNAME pngcrush $TEMPNAME /tmp/$TEMPNAME && mv /tmp/$TEMPNAME $TEMPNAME # Then ask for screenshot name; if cancel is pressed, delete the temp file and exit SHOTSIZE=`du -b -h $TEMPNAME | cut -f 1` SHOTNAME=`zenity --entry --text="Screenshot is $SHOTSIZE, enter name or press \"Cancel\" to delete"` if [[ -z "$SHOTNAME" ]]; then rm $TEMPNAME; exit 1; fi # Give the screenshot its final name SHOTNAME=$NAMEPREFIX$SHOTNAME.png mv $TEMPNAME $SHOTNAME if [[ -n "$BASEURL" ]]; then zenity --entry --text="Screenshot is $SHOTSIZE, copy-paste the URL or press \"Cancel\" to delete" --entry-text="$BASEURL$SHOTNAME" || rm $SHOTNAME fi