1#!/bin/bash
2trap "" TERM
3context=`id -Z | secon -t -l -P`
4export TITLE="Sandbox $context -- `grep ^#TITLE: ~/.sandboxrc | /usr/bin/cut -b8-80`"
5[ -z $1 ] && export SCREENSIZE="1000x700" || export SCREENSIZE="$1"
6[ -z $2 ] && export DPI="96" || export DPI="$2"
7trap "exit 0" HUP
8
9mkdir -p ~/.config/openbox
10cat > ~/.config/openbox/rc.xml << EOF
11<openbox_config xmlns="http://openbox.org/3.4/rc"
12		xmlns:xi="http://www.w3.org/2001/XInclude">
13<applications>
14  <application class="*">
15    <decor>no</decor>
16    <desktop>all</desktop>
17    <maximized>yes</maximized>
18  </application>
19</applications>
20</openbox_config>
21EOF
22
23(/usr/bin/Xephyr -resizeable -title "$TITLE" -terminate -screen $SCREENSIZE -dpi $DPI -nolisten tcp -displayfd 5 5>&1 2>/dev/null) | while read D; do
24    export DISPLAY=:$D
25    cat > ~/seremote << __EOF
26#!/bin/sh
27DISPLAY=$DISPLAY "\$@"
28__EOF
29    chmod +x ~/seremote
30    /usr/share/sandbox/start $HOME/.sandboxrc
31    export EXITCODE=$?
32    kill -TERM 0
33    break
34done
35exit 0
36