/[scripts]/trunk/webthumb
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/webthumb

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2 by dpavlin, Mon Jul 26 13:28:53 2004 UTC revision 60 by dpavlin, Wed Feb 6 19:48:56 2008 UTC
# Line 35  H=768 Line 35  H=768
35    
36  # some configurable paths  # some configurable paths
37  BROWSER=mozilla-firefox  BROWSER=mozilla-firefox
38  XSERVER=vncserver  XSERVER=Xvfb
39  XWIT=xwit  XWIT=xwit
40  URL=$1  URL=$1
41  FILE=${2:-screenshot.jpg}  FILE=${2:-screenshot.jpg}
42    
43  FRAMESET="`mktemp`.html"  FRAMESET="`mktemp`.html"
44    PROFILE_DIR=`mktemp -d`
45  PORT=8888  PORT=8888
46    
47  if [ -z "$URL" ] ; then  if [ -z "$URL" ] ; then
# Line 49  if [ -z "$URL" ] ; then Line 50  if [ -z "$URL" ] ; then
50  fi  fi
51    
52  if [ -z "`which $XWIT`" ] ; then  if [ -z "`which $XWIT`" ] ; then
53          echo "$0 really need xwit to operate. please install it."          echo "$0 really need $XWIT to operate. please install it."
54            exit 1
55    fi
56    
57    if [ -z "`which $XSERVER`" ] ; then
58            echo "$0 really need $XSERVER to operate. please install it."
59          exit 1          exit 1
60  fi  fi
61    
# Line 61  else Line 67  else
67          exit 1          exit 1
68  fi  fi
69    
70  echo "starting vnc X server"  echo "starting X server $XSERVER"
71    
72    export DISPLAY=:42
73    
74  export DISPLAY=`$XSERVER -geometry ${W}x${H} -depth 24 2>&1 \  $XSERVER -ac -screen 0 ${W}x${H}x24 $DISPLAY &
75          | grep : | head -1 | cut -d: -f2 | sed 's/^/:/'`  # debug server
76    #Xnest -display :0 -ac -geometry ${W}x${H} -depth 24 $DISPLAY &
77    
78  function kill_vnc() {  XSERVER_PID=$!
79          vncserver -kill $DISPLAY  echo "using pid $xserver_pid for X server"
80    
81    function kill_x_server() {
82            kill $BROWSER_PID
83            kill $XSERVER_PID
84          rm -f $FRAMESET          rm -f $FRAMESET
85            rm -fr $PROFILE_DIR
86  }  }
87  trap 'echo "QUIT!" >&2; kill_vnc; exit 1' INT QUIT TERM SEGV  trap 'echo "QUIT!" >&2; kill_x_server; exit 1' INT QUIT TERM SEGV
88    
89  # create frameset to load site and after site is loaded trigger this script  # create frameset to load site and after site is loaded trigger this script
90  cat > $FRAMESET <<END_OF_FRAMESET  cat > $FRAMESET <<END_OF_FRAMESET
# Line 86  END_OF_FRAMESET Line 100  END_OF_FRAMESET
100    
101  echo "Using frameset html $FRAMESET"  echo "Using frameset html $FRAMESET"
102    
103  echo "preview available with: vncviewer $DISPLAY"  echo "preview available with: xwd -display $DISPLAY -root | xwud"
104    
105  echo "making 'Screenshot' profile"  echo "making 'Screenshot' profile in $PROFILE_DIR"
106  $BROWSER -CreateProfile Screenshot | grep Success  $BROWSER -CreateProfile "Screenshot $PROFILE_DIR" | grep Success
107    
108  echo "launching browser $BROWSER with $URL"  echo "launching browser $BROWSER with $URL"
109  $BROWSER -id Screenshot -P Screenshot -width $W -height $H $FRAMESET 2>&1 >/dev/null &  $BROWSER -P Screenshot -width $W -height $H $FRAMESET &
110    BROWSER_PID=$!
111    
112  echo "staring web server (wait for page to load)"  echo "staring web server (wait for page to load)"
113    
# Line 102  echo "staring web server (wait for page Line 117  echo "staring web server (wait for page
117  echo -e "HTTP/1.0 304 Not modified\r\n\r\n" | nc -l -w 60 -p $PORT >/dev/null  echo -e "HTTP/1.0 304 Not modified\r\n\r\n" | nc -l -w 60 -p $PORT >/dev/null
118    
119  # get Mozilla Firefox window id (for resize)  # get Mozilla Firefox window id (for resize)
120    WINDOW_ID=`xwininfo -display $DISPLAY -root -tree | grep gecko | cut -d\" -f1 | sort -n | head -1`
 WINDOW_ID=`xwininfo -display $DISPLAY -name "Mozilla Firefox" | grep "Window id:" | cut -d" " -f4`  
121    
122  if [ -z "$WINDOW_ID" ] ; then  if [ -z "$WINDOW_ID" ] ; then
123          echo "can't find window with name 'Mozilla Firefox'"          echo "can't find window with name 'Mozilla Firefox'"
# Line 138  echo "saving window $DUMP_ID to $FILE" Line 152  echo "saving window $DUMP_ID to $FILE"
152  if [ ! -z "$RESIZE" ] ; then  if [ ! -z "$RESIZE" ] ; then
153          RESIZE="-geometry $RESIZE"          RESIZE="-geometry $RESIZE"
154  fi  fi
155    
156  import -window $DUMP_ID $RESIZE $FILE  import -window $DUMP_ID $RESIZE $FILE
157    
158  kill_vnc  kill_x_server
159    

Legend:
Removed from v.2  
changed lines
  Added in v.60

  ViewVC Help
Powered by ViewVC 1.1.26