summaryrefslogtreecommitdiff
path: root/firestartx
blob: 748b9dd3491531f9bed3a524b1565eeaa5e2341c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/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