tAdded help and gif function - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 1121c6b8f1793b4d91236cfd926edb9dbedeecd7
(DIR) parent 3854c8c6a531a3053f75f86c890fcf1e9485c90e
(HTM) Author: Willy Goiffon <w.goiffon@gmail.com>
Date: Thu, 5 Sep 2013 15:11:09 +0200
Added help and gif function
Diffstat:
M instagram | 55 ++++++++++++++++++++-----------
1 file changed, 35 insertions(+), 20 deletions(-)
---
(DIR) diff --git a/instagram b/instagram
t@@ -3,22 +3,30 @@
SSHOT_DIR=~/usr/img/scrn
function usage() {
- echo 'help!'
+ cat <<SHBLAH
+Usage : instagram [-tmh] [-g time] [-s screen] [filename.png]
+ -t : create thumbnail
+ -m : create one shot per head
+ -h : display this help
+ -g time : create a gif during <time> seconds
+ -s screen : use only the screen number <screen> for the shot
+
+Remember to add an extension at the end of the command
+Also, do not give path to shot. They're saved to $SSHOT_DIR by default.
+SHBLAH
}
-[[ $# -eq 0 ]] && exit 1
-
-if [ $# -gt 1 ]; then
- while getopts ":tms:o:h" opt; do
- case $opt in
- t) THUMB=1 ;;
- m) MULTI=1 ;;
- s) SCREEN=$OPTARG ;;
- h) usage ; exit ;;
- \?) echo "invalid option: -$OPTARG"; exit 1 ;;
- esac
- done
-fi
+while getopts ":htmdg:s:" opt; do
+ case $opt in
+ t) THUMB=1 ;;
+ m) MULTI=1 ;;
+ d) SSHOT_DIR=$OPTARG ;;
+ g) GIF=$OPTARG ;;
+ s) SCREEN=$OPTARG ;;
+ h) usage; exit ;;
+ ?) echo "invalid option: -$OPTARG"; exit 1 ;;
+ esac
+done
shift $((OPTIND-1))
t@@ -33,14 +41,21 @@ if [[ "$MULTI" = "1" ]] || [[ -n $SCREEN ]]; then
xdpyinfo -ext XINERAMA | sed '/^ head #/!d;s///' |
while IFS=' :x@,' read i w h x y; do
if [[ $SCREEN = "$i" ]] || [[ -z $SCREEN ]]; then
- import -window root -crop ${w}x$h+$x+$y $SSHOT_DIR/head_$i-$1
- [[ -n $THUMB ]] && import -window root -thumbnail 25% -crop ${w}x$h+$x+$y $SSHOT_DIR/thumb-head_$i-$1
+ import -window root -crop ${w}x$h+$x+$y $SSHOT_DIR/head_$i-$OUTPUT
+ [[ -n $THUMB ]] && import -window root -thumbnail 25% -crop ${w}x$h+$x+$y $SSHOT_DIR/thumb-head_$i-$OUTPUT
fi
done
+elif [ -n "$GIF" ]; then
+ mkdir $SSHOT_DIR/tmp
+ for i in $(seq 0 $GIF); do
+ import -window root $SSHOT_DIR/tmp/gif${i}_${OUTPUT}
+ sleep 0.5
+ done
+ convert -delay 100 -loop 0 $SSHOT_DIR/tmp/gif*$OUTPUT $SSHOT_DIR/${1/jpg/gif}
else
-
- import -window root $SSHOT_DIR/$1
- [[ -n $THUMB ]] && import -window root -thumbnail 25% $SSHOT_DIR/thumb-$1
-
+ import -window root $SSHOT_DIR/$OUTPUT
+ [[ -n $THUMB ]] && import -window root -thumbnail 25% $SSHOT_DIR/thumb-$OUTPUT
fi
+
+meh $SSHOT_DIR/$OUTPUT