~xavi-garcia-mena/ubuntu-touch-session/bug-1317860-env-variable-poweroff

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
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh

# WARNING: this wrapper is only for setting up screen environment variables
# that would need to be shared between a greeter process and the user session.
# Do NOT add any other hacks here.  We eventually intend for this wrapper to
# go away, once we dynamically determine screen settings.

export QT_QPA_PLATFORM=ubuntumirclient

# defaults
GRID_UNIT_PX=18
QTWEBKIT_DPR=2.0
NATIVE_ORIENTATION=portrait

# override defaults by sourcing /etc/ubuntu-touch-session.d/$device.conf
device=$(getprop ro.product.device)
if [ -e /etc/ubuntu-touch-session.d/$device.conf ]; then
    . /etc/ubuntu-touch-session.d/$device.conf
else
    # android.conf is used by the bind mount
    . /etc/ubuntu-touch-session.d/android.conf
fi

# Workaround for bug 1308210 / 1318070 (x86 emulator and scopes)
if [ $(getprop ro.kernel.qemu 0) -eq 1 ]; then
    cpu_mhz=$(grep -m1 "cpu MHz" /proc/cpuinfo | awk -F' ' '{ print $4 }')
    if [ "$cpu_mhz" = "0.000" ]; then
        export RDTSC_FREQUENCY=2000
    fi
fi

# Set up xdg dirs
[ -z "$XDG_CONFIG_DIRS" ] && export XDG_CONFIG_DIRS=/etc/xdg
[ -z "$XDG_DATA_DIRS" ] && export XDG_DATA_DIRS=/usr/local/share:/usr/share
if [ -n "$DESKTOP_SESSION" ]; then
    export XDG_CONFIG_DIRS=/etc/xdg/xdg-$DESKTOP_SESSION:$XDG_CONFIG_DIRS
    export XDG_DATA_DIRS=/usr/share/$DESKTOP_SESSION:$XDG_DATA_DIRS
fi

# if /custom/xdg/config exists, add it to xdg_config_dirs. this is so upstart can get job definitions from /custom
if [ -d /custom/xdg/config ]; then
	export XDG_CONFIG_DIRS=/custom/xdg/config:$XDG_CONFIG_DIRS
fi

export GRID_UNIT_PX=${GRID_UNIT_PX}
export QTWEBKIT_DPR=${QTWEBKIT_DPR}
export NATIVE_ORIENTATION=${NATIVE_ORIENTATION}

# Save in bashrc so that adb picks them up (for autopilot's benefit)
dot_profile=$HOME/.profile
grep -q GRID_UNIT_PX $dot_profile || echo "export GRID_UNIT_PX=${GRID_UNIT_PX}" >> $dot_profile
grep -q QTWEBKIT_DPR $dot_profile || echo "export QTWEBKIT_DPR=${QTWEBKIT_DPR}" >> $dot_profile
grep -q NATIVE_ORIENTATION $dot_profile || echo "export NATIVE_ORIENTATION=${NATIVE_ORIENTATION}" >> $dot_profile
grep -q XDG_CONFIG_DIRS $dot_profile || echo "export XDG_CONFIG_DIRS=${XDG_CONFIG_DIRS}" >> $dot_profile
grep -q XDG_DATA_DIRS $dot_profile || echo "export XDG_DATA_DIRS=${XDG_DATA_DIRS}" >> $dot_profile

if [ "$#" -ne 0 ]; then
    exec $@
else
    exec init --user
fi