#!/bin/sh
# Launch a nested session inside FVWM-Crystal using Xephyr
# Syntax: launchwm $[vp.width] $[vp.height] <wm>

# next free $DISPLAY, needed for nested wm in nested wm :)
XephyrDisplay=$((`echo $DISPLAY|cut -d: -f2|cut -d. -f1`+1))
# nested session dimension; you can change it
XephyrWidth=$((`echo $(($1-200))`))
XephyrHeight=$((`echo $(($2-100))`))

EXECWM=`grep Exec $3 | grep -v Try | sed -e 's:Exec=::'`

# launch Xephyr
#Xephyr -ac -reset -fullscreen :$XephyrDisplay &
#Xephyr -ac -reset -screen 1200x800 :$XephyrDisplay &
Xephyr -ac -reset -title `basename $EXECWM` -screen "$XephyrWidth"x"$XephyrHeight" :$XephyrDisplay &
# wait Xephyr
sleep 1
# launch the wm
DISPLAY=:$XephyrDisplay $EXECWM 2>/dev/null

# TODO: launch the wm in fullscreen
