diff options
| author | marco giusti <marco.giusti@gmail.com> | 2011-12-06 00:34:26 +0100 |
|---|---|---|
| committer | marco giusti <marco.giusti@gmail.com> | 2011-12-06 00:34:26 +0100 |
| commit | aec2740cc698b5b8c7e59cdcd7ab3a05d12716f9 (patch) | |
| tree | a198d3f9194fd6bba18b25dabdc692ff51574c6c /docs/tools | |
| parent | f0f72e2f606b8b3a5189c4d5e637a543708cd07c (diff) | |
| download | urwid-aec2740cc698b5b8c7e59cdcd7ab3a05d12716f9.tar.gz | |
Add screenshots.sh and compile_pngs.sh
Substitute old images with the new ones generated by the new scripts
--HG--
branch : feature-sphinx
Diffstat (limited to 'docs/tools')
| -rwxr-xr-x | docs/tools/compile_pngs.sh | 20 | ||||
| -rwxr-xr-x | docs/tools/screenshots.sh | 26 |
2 files changed, 46 insertions, 0 deletions
diff --git a/docs/tools/compile_pngs.sh b/docs/tools/compile_pngs.sh new file mode 100755 index 0000000..b74cc51 --- /dev/null +++ b/docs/tools/compile_pngs.sh @@ -0,0 +1,20 @@ +#!/bin/bash -e + +# $1: directory to compile +DISPLAYNUM=1 + +XVFB=$(which Xvfb) +if [ -n $XVFB ]; then + # Xvfb :$DISPLAYNUM &> /dev/null & + Xvfb :$DISPLAYNUM & + XVFBPID=$! + # DISPLAY=:1 + sleep 0.5 + trap "kill $XVFBPID" EXIT +fi + +for script in $1/*.py; do + if [ -f "${script}.xdotool" ]; then + bash screenshots.sh "$script" < "${script}.xdotool" + fi +done diff --git a/docs/tools/screenshots.sh b/docs/tools/screenshots.sh new file mode 100755 index 0000000..d6d1f62 --- /dev/null +++ b/docs/tools/screenshots.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# $1: python script to run +# urxvt, xdotool and import are required to run this script + +# this should be pretty unique, but a true random classname is still possible +# CLASSNAME=$(head -c 6 /dev/urandom | base64) +CLASSNAME=urwid-screenshot +PYTHON=python + +urxvt -bg gray90 -b 0 +sb -name "$CLASSNAME" -e "$PYTHON" "$1" & +RXVTPID=$! +sleep 0.2 +RXVTWINDOWID=$(xdotool search --classname "$CLASSNAME") +export RXVTWINDOWID +image=${1%.py} + +c=1 +while read -r line; do + # the echo trick is needed to expand RXVTWINDOWID variable + echo $line | xdotool - + import -window "$RXVTWINDOWID" "${image}$c.png" + (( c++ )) +done + +kill $RXVTPID |
