tinstagram - scripts - various script and utils
HTML git clone git://z3bra.org/scripts
DIR Log
DIR Files
DIR Refs
---
tinstagram (1945B)
---
1 #!/bin/bash
2 #
3 # 2013 z3bra <willy at mailoo dot org>
4 # INSTAGRAM - screenshot taker / manager
5 #
6 # Licensed under WTFPL 2.0
7 # >> http://www.wtfpl.net/txt/copying/
8 #
9
10 VIEWER=meh
11 EXEC_UPLOAD=~/bin/imgurup
12 WMNAME=`xprop -root WM_NAME|cut -d\" -f2`
13
14 upload() {
15 $EXEC_UPLOAD $1
16 }
17
18 usage() {
19 cat <<SHBLAH
20 Usage : instagram [-tmuwh] [-g number] [-s screen] [filename.png]
21 -t : create thumbnail
22 -u : upload the file using $UPLOAD_BIN <filename>
23 -w : take only a window for the shot (choose with pointer)
24 -h : display this help
25 -d path : save the shot in <path>
26 -s screen : use only the screen number <screen> for the shot
27
28 Also, do not give path to shot. They're saved to $SSHOT_DIR by default.
29
30 Configuration:
31 instagram sources $USER/.config/instagram at start.
32 You can set variables here, so that they will overide the default ones:
33
34 IMAGE_DIR : Where images are stored
35 EXEC_UPLOAD : Path to the script/program used to upload your shot
36 SHBLAH
37 }
38
39 headshot() {
40
41 xdpyinfo -ext XINERAMA | sed 's/^ head #//p' |
42 while IFS=' :x@,' read i w h x y; do
43 if [[ $1 = "$i" ]]; then
44 import -window $WINDOW -crop ${w}x${h}+${x}+${y} $OUTPUT
45 fi
46 done
47 }
48
49 [[ "$1" = "--help" ]] && usage && exit 0
50
51 while getopts ":htmuwgs:" opt; do
52 case $opt in
53 t) THUMB=1 ;;
54 s) SCREEN=$OPTARG ;;
55 u) UPLOAD=1 ;;
56 w) WINDOW=`xprop|grep 'window id'|cut -d\ -f7`;;
57 h) usage; exit 0;;
58 ?) echo "invalid option: -$OPTARG"; exit 1 ;;
59 esac
60 done
61
62 shift $((OPTIND-1))
63
64 test -z $1 && OUTPUT=$WMNAME-`date +%Y-%m-%d`.png || OUTPUT=$1
65 test -z "$WINDOW" && WINDOW='root'
66
67 if [ -n "$SCREEN" ]; then
68 headshot $SCREEN
69 else
70 import -window ${WINDOW} $OUTPUT
71 fi
72
73 test -n "$THUMB" && import -window ${WINDOW} -thumbnail 25% thumb-$(basename ${OUTPUT})
74
75
76 $VIEWER $OUTPUT
77
78 test "$UPLOAD" = "1" && upload ${OUTPUT}