on bionic help sign in
unity8/data/unity8-greeter-wrapper
93 lines 3.5 kB history raw
1#!/bin/sh
2# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 4 -*-
3#
4# Copyright (C) 2011,2013,2016 Canonical Ltd
5#
6# This program is free software: you can redistribute it and/or modify it under
7# the terms of the GNU General Public License as published by the Free Software
8# Foundation, version 3 of the License.
9#
10# See http://www.gnu.org/copyleft/gpl.html the full text of the license.
12# This wrapper merely ensures that init and friends live only as long as this
13# script does. Otherwise, it's very easy for some processes to not notice that
14# the session died. We could try to do this in-process, but we want to do this
15# cleanup even if the greeter aborts.
17trap cleanup TERM EXIT
19cleanup()
21 trap - TERM EXIT
22 # Kill upstart and indicators
23 if [ -n "$IND_PID" ]; then
24 kill "$IND_PID"
25 fi
26 if [ -n "$CMD_PID" ]; then
27 kill "$CMD_PID"
28 fi
29 exit 0
32set_greeter_var()
34 export "$1=$2"
35 dbus-update-activation-environment --systemd "$1=$2"
38SUB_SOCKET=$XDG_RUNTIME_DIR/mir_socket
39rm -f $SUB_SOCKET # clear socket in case we were hard shut down
41echo "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}" >"$XDG_RUNTIME_DIR/dbus-session"
43# If touch session script (which sets up grid units and mir variables) is available, use it
44TOUCH_WRAPPER=
45if which ubuntu-touch-session >/dev/null; then
46 TOUCH_WRAPPER=ubuntu-touch-session
47fi
49# Advertise as a unity8 session, so that indicator-network will start.
50export XDG_SESSION_DESKTOP=unity8
51export DESKTOP_SESSION=$XDG_SESSION_DESKTOP
53set_greeter_var QT_IM_MODULE maliitphablet
54set_greeter_var QT_QPA_PLATFORM ubuntumirclient
56# We disable ofono using pulse. It causes problems with racing with the user's
57# pulse. We need to come up with a better long-term fix for this, because we
58# eventually need the greeter to play ringtones for users that aren't logged in.
59set_greeter_var PA_DISABLED 1
61# Start the indicators
62/usr/lib/gnome-session/run-systemd-session indicators.target &
63IND_PID=$!
65# Start any pre-greeter tasks if needed (like wizard)
66#initctl emit unity8-greeter-starting FIXME
68# Define language here for phone if available. When phone user switches their
69# language, they expect that to affect the greeter too. But the user doesn't
70# have permission to switch system language, only their own. So we notice if
71# the phablet user exists and use their language if so. TODO: talk to design
72# about whether we should switch language on fly as users are selected (this
73# is very hard to do technically).
75# Do this after unity8-greeter-starting, in case a customization upstart job
76# changes language.
77if [ "$(id -u phablet 2>/dev/null)" = "32011" ]; then
78 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)
79 if [ -n "$USER_LANG" ]; then
80 set_greeter_var LANGUAGE "$USER_LANG"
81 fi
82 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)
83 if [ -n "$USER_LOCALE" ]; then
84 set_greeter_var LANG "$USER_LOCALE"
85 set_greeter_var LC_ALL "$USER_LOCALE"
86 fi
87fi
89# And finally actually start the greeter
90exec env MIR_SERVER_FILE=$SUB_SOCKET $TOUCH_WRAPPER $@ &
91CMD_PID=$!
92wait $CMD_PID
93CMD_PID=