on cf40464 help sign in
unity8/data/unity8-greeter-wrapper
98 lines 4.1 kB history raw
1#!/bin/sh
2# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 4 -*-
3#
4# Copyright (C) 2011,2013 Canonical Ltd
5# Author: Michael Terry <michael.terry@canonical.com>
6#
7# This program is free software: you can redistribute it and/or modify it under
8# the terms of the GNU General Public License as published by the Free Software
9# Foundation, version 3 of the License.
11# See http://www.gnu.org/copyleft/gpl.html the full text of the license.
13# This wrapper merely ensures that init and friends live only as long as this
14# script does. Otherwise, it's very easy for some processes to not notice that
15# the session died. We could try to do this in-process, but we want to do this
16# cleanup even if the greeter aborts.
18trap cleanup TERM EXIT
20cleanup()
22 trap - TERM EXIT
23 # Kill upstart and indicators
24 if [ -n "$INIT_PID" ]; then
25 kill "$INIT_PID"
26 fi
27 if [ -n "$CMD_PID" ]; then
28 kill "$CMD_PID"
29 fi
30 exit 0
33set_greeter_var()
35 export "$1=$2"
36 gdbus call --session --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus --method org.freedesktop.DBus.UpdateActivationEnvironment "{'$1': '$2'}"
37 if [ -n "$INIT_PID" ]; then
38 initctl set-env --global "$1=$2"
39 fi
42SUB_SOCKET=$XDG_RUNTIME_DIR/mir_socket
43rm -f $SUB_SOCKET # clear socket in case we were hard shut down
45# If touch session script (which sets up grid units and mir variables) is available, use it
46TOUCH_WRAPPER=
47if [ -x /usr/bin/ubuntu-touch-session ]; then
48 TOUCH_WRAPPER=/usr/bin/ubuntu-touch-session
49fi
51# Pretend that we're in an ubuntu-touch session, so that indicator-network
52# will start.
53export DESKTOP_SESSION=ubuntu-touch
55# We disable ofono using pulse. It causes problems with racing with the user's
56# pulse. We need to come up with a better long-term fix for this, because we
57# eventually need the greeter to play ringtones for users that aren't logged in.
58set_greeter_var PA_DISABLED 1
60# Normal unity8 sessions are entirely driven by Upstart. But greeters
61# are special. They need access to the file descriptors that lightdm
62# creates for them and don't want to start all the services that a normal
63# session would. So it's inconvenient to live within an upstart session.
64# But... we still want to use Upstart for some services. So launch here.
65USC_SOCKET=$MIR_SOCKET MIR_SOCKET=$SUB_SOCKET $TOUCH_WRAPPER /sbin/init --user --no-startup-event &
66INIT_PID=$!
67while [ ! -e "$XDG_RUNTIME_DIR/upstart/sessions/$INIT_PID.session" ]; do sleep 0.1; done
68export UPSTART_SESSION=$(/sbin/initctl list-sessions | grep "^$INIT_PID " | cut -d' ' -f2)
70# Start any pre-greeter tasks if needed (like wizard)
71/sbin/initctl emit unity8-greeter-starting
73# Define language here for phone if available. When phone user switches their
74# language, they expect that to affect the greeter too. But the user doesn't
75# have permission to switch system language, only their own. So we notice if
76# the phablet user exists and use their language if so. TODO: talk to design
77# about whether we should switch language on fly as users are selected (this
78# is very hard to do technically).
80# Do this after unity8-greeter-starting, in case a customization upstart job
81# changes language.
82if [ "$(id -u phablet 2>/dev/null)" = "32011" ]; then
83 USER_LANG=$(gdbus call --system --dest org.freedesktop.Accounts --object-path /org/freedesktop/Accounts/User32011 --method org.freedesktop.DBus.Properties.Get org.freedesktop.Accounts.User Language | cut -d\' -f2)
84 if [ -n "$USER_LANG" ]; then
85 set_greeter_var LANGUAGE "$USER_LANG"
86 fi
87 USER_LOCALE=$(gdbus call --system --dest org.freedesktop.Accounts --object-path /org/freedesktop/Accounts/User32011 --method org.freedesktop.DBus.Properties.Get org.freedesktop.Accounts.User FormatsLocale | cut -d\' -f2)
88 if [ -n "$USER_LOCALE" ]; then
89 set_greeter_var LANG "$USER_LOCALE"
90 set_greeter_var LC_ALL "$USER_LOCALE"
91 fi
92fi
94# And finally actually start the greeter
95exec env MIR_SERVER_FILE=$SUB_SOCKET $TOUCH_WRAPPER $@ &
96CMD_PID=$!
97wait $CMD_PID
98CMD_PID=