#!/bin/sh
# Xephyr test wrapper.
# Andrew Chadwick, 2012. Public domain, do what you like with it.
# 
# Runs a binary under a particular window manager, without a DE, and with a
# small screen size.

# Display to create: you may need to tweak this.
DISP=":3"

# Window manager to run with.
WM="$1"
if [ -z "$WM" ] ; then
    echo >&2 "usage: $0 WMEXEC ARGV"
    exit 2
fi
shift
EXEC="$1"
shift
echo "WM: $WM"
echo "EXEC: $EXEC (args: $@)"

Xephyr "$DISP" -once -retro -screen 800x600 &
xephyr_pid=$!
export DISPLAY="$DISP"
sleep 2
xsetroot -cursor_name watch -solid '#666'
$WM &
sleep 1
xsetroot -cursor_name left_ptr -solid '#666'
# Launch the app
"$EXEC" "$@"
# Give the app a chance to save prefs after its window is destroyed
sleep 2
kill $xephyr_pid
