www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

gui-wrapper.sh (1475B)


      1 #!/bin/sh
      2 
      3 set -e
      4 
      5 resolution="$1" # e.g. 800x600x24 (width x height x bits_per_pixel)
      6 shift           # the following arguments are the program to execute and its arguments
      7 
      8 bg="build/checkerboard_$(echo "$resolution" | cut -d 'x' -f1-2).xbm"
      9 twm_session_dir="$(./utils/mktemp.sh -d)"
     10 anim="$(./utils/mktemp.sh -d)"
     11 
     12 # Create checkerboard background
     13 # Use +level-colors 'gray(192),gray(128)' to choose directly the colors.
     14 #   Since we're creating an .xbm for xsetroot, we'll use black and white
     15 #   and choose the colors with xsetroot.
     16 convert -size "$(echo "$resolution" | cut -d 'x' -f1-2)" \
     17         tile:pattern:checkerboard \
     18         -auto-level \
     19         "$bg"
     20 
     21 cat > "build/twm_cfg" <<EOF
     22 RandomPlacement
     23 EOF
     24 
     25 echo "$bg $anim $resolution $@"
     26 # -fg chocolate -bg coral looks nice too :)
     27 xvfb-run -a --server-args="-screen 0 ${resolution}" sh -c 'sleep 2; SM_SAVE_DIR="'"$twm_session_dir"'" twm -f "'"build/twm_cfg"'" & sleep 1 && xsetroot -bitmap "'"$bg"'" -fg gray75 -bg gray50 && sleep 1 && ./utils/screenshots-loop.sh x11 "'"$anim"'" & "$@"' ./utils/gui-wrapper.sh-subshell "$@"
     28 
     29 touch "$anim/stop-screenshots"
     30 anim_done=false
     31 for i in `seq 300`; do if test -e "$anim/anim-done"; then anim_done=true; break; fi; sleep 1; done
     32 if $anim_done; then echo "anim: done ($*)"; else echo "anim: timeout ($*)"; fi
     33 if test -e "$anim/anim.gif"; then
     34   mv "$anim/anim.gif" "./deploy-screenshots/$(basename "$1" .sh)-anim.gif"
     35 fi
     36 
     37 # Cleanup
     38 rm -r -- "$twm_session_dir" "$anim"