#!/bin/bash get_new_display() { for ((n=1; n<99; ++n)) do if [ ! -e /tmp/.X$n-lock ] then NEW_DISPLAY=:$n return fi done false } get_new_display || exit if [ $# = 0 ] then set -- firestart fi # TITLE=$* # lol, startx doesn't support arguments with spaces TITLE=$1 if [ "$1" != firestart ] then USE_XINIT=y fi if [ "$USE_XINIT" ] then set -x case "$1" in /*) ;; *) f1=$(which "$1") || exit shift set -- "$f1" "$@" ;; esac xinit "$@" -- $(which Xephyr) "$NEW_DISPLAY" -resizeable -p 0 -terminate ${TITLE:+ -title "$TITLE"} else set -x startx -- $(which Xephyr) "$NEW_DISPLAY" -resizeable -p 0 -terminate ${TITLE:+ -title "$TITLE"} & if [ $# -gt 0 ] then DISPLAY=$NEW_DISPLAY "$@" & fi wait fi