Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/commands/run
blob: 1f043d041026d5dbb0ac389f82f81a741866cef4 (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

commandsdir=$(dirname $(readlink -f $0))
helpersdir=$commandsdir/helpers
rootdir=`dirname "$commandsdir"`
display=`$helpersdir/find-free-display`

$commandsdir/check-system --skip-if-unchanged

if [ -f $rootdir/prefs ]; then
    source $rootdir/prefs
fi

if [ ! -z $DISPLAY ]; then
    SUGAR_XKBCONFIG=`mktemp -t sugar-xkbconfig-XXXXXX`
    setxkbmap -print > $SUGAR_XKBCONFIG
    export SUGAR_XKBCONFIG
fi

if [ ! -z $SUGAR_PROFILE ]; then
    grep -q PROFILE $rootdir/prefs
    if [ $? -eq 1 ]; then
        randomstring=`</dev/urandom tr -cd A-Za-z0-9 | head -c10`
        echo "PROFILE=$randomstring" >> $ROOT_DIR/prefs
    fi
fi

if [ -z $DISPLAY ]; then
    tty_num=`tty | grep -oE '[0-9]+$'`
    x_options="vt$tty_num"

    xinit $helpersdir/xinitrc -- $display $x_options
else
    screen_dpi=`$helpersdir/get-screen-dpi`
    xephyr_options="-dpi $screen_dpi"

    xidfile=`mktemp -t sugar-xephyr-xid-XXXXXX`
    $helpersdir/xephyr-window $RESOLUTION > $xidfile &
    xephyrwindowpid=$!

    while [ ! -s $xidfile ]
    do
        sleep 1
    done

    xephyr_options="$xephyr_options -parent `cat $xidfile`"
    xinit $helpersdir/xinitrc -- /usr/bin/Xephyr $display $xephyr_options

    kill $xephyrwindowpid
fi