@@ -20,28 +20,32 @@ env QML_NO_TOUCH_COMPRESSION=1
2020respawn
2121expect stop
2222
23+# FIXME Create an autopilot test that makes sure start+stop and restart
24+# work fine at least 2 times
25+
2326pre-start script
2427 # Tell unity-mir to raise SIGSTOP after we start
2528 initctl set-env UNITY_MIR_EMITS_SIGSTOP=1
2629
27− if [ -n "$MIR_SOCKET" ]; then
28− # FIXME Create an autopilot test that makes sure start+stop and restart
29− # work fine at least 2 times
30− # Save original value of MIR_SOCKET in case we are stopped,
31− # as we modify the variable for future jobs, including ourself.
32− UNITY_MIR_SOCKET=$(initctl get-env --global MIR_SOCKET)
33− initctl set-env --global UNITY_MIR_SOCKET=$UNITY_MIR_SOCKET
30+ # Save original value of MIR_SOCKET so that we can restore it when stopped,
31+ # as we modify the variable for future jobs, including ourself.
32+ initctl set-env UNITY_MIR_SOCKET=$MIR_SOCKET
3433
35− # Point unity8 at unity-system-compositor
34+ # Decide where we are going to put our own socket file
35+ if [ -n "$SNAP" ]; then
36+ # In snappy, we want to hard code our path because our apparmor profile
37+ # only lets us put the socket in one place. And consumers expect it
38+ # there.
39+ MIR_SERVER_FILE=/run/user/$(id -u)/mir_socket
40+ else
3641 MIR_SERVER_FILE=$XDG_RUNTIME_DIR/mir_socket
37− initctl set-env MIR_SERVER_FILE=$MIR_SERVER_FILE
38− initctl set-env MIR_SERVER_HOST_SOCKET=$UNITY_MIR_SOCKET
39−
40− # Point all future jobs in this session to our Mir socket instead of
41− # unity-system-compositor's socket.
42− initctl set-env --global MIR_SOCKET=$MIR_SERVER_FILE
43− gdbus call --session --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus --method org.freedesktop.DBus.UpdateActivationEnvironment "@a{ss} {'MIR_SOCKET': '$MIR_SERVER_FILE'}"
4442 fi
43+ initctl set-env MIR_SERVER_FILE=$MIR_SERVER_FILE
44+
45+ # Point all future jobs in this session to our Mir socket instead of
46+ # unity-system-compositor's socket.
47+ initctl set-env --global MIR_SOCKET=$MIR_SERVER_FILE
48+ gdbus call --session --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus --method org.freedesktop.DBus.UpdateActivationEnvironment "@a{ss} {'MIR_SOCKET': '$MIR_SERVER_FILE'}"
4549
4650 # Remove the normal and trusted sockets if still there
4751 if [ -S "$MIR_SERVER_FILE" ]; then
@@ -54,12 +58,6 @@ pre-start script
5458
5559 initctl set-env --global MIR_SERVER_PROMPT_FILE=1
5660
57− #
58− # Mir's input resampling is deprecated and going away soon. Turn it off
59− # so we don't get a surprise change in behaviour when that happens.
60− #
61− initctl set-env --global MIR_CLIENT_INPUT_RATE=0
62−
6361 if [ "$XDG_SESSION_DESKTOP" = "ubuntu-touch" ]; then
6462 # On Ubuntu Touch, we currently use a trick where we auto-login the
6563 # user without a LightDM greeter at all. In this case, we want to
@@ -74,25 +72,11 @@ end script
7472exec ${BINARY:-unity8} --mode=$MODE $ARGS
7573
7674post-start script
77− # If no MIR_SOCKET was defined on launch, we try to set one here
78− if [ -z "$(initctl get-env --global UNITY_MIR_SOCKET)" ]; then
79− if [ -S "$XDG_RUNTIME_DIR/mir_socket" ]; then
80− mir_socket=$XDG_RUNTIME_DIR/mir_socket
81− elif [ -S "/tmp/mir_socket" ]; then
82− mir_socket=/tmp/mir_socket
83− fi
84−
85− if [ -n "$mir_socket" ]; then
86− initctl set-env --global MIR_SOCKET="$mir_socket"
87− fi
88− fi
89−
9075 initctl emit --no-wait indicator-services-start
9176end script
9277
9378post-stop script
9479 initctl set-env --global MIR_SOCKET=$UNITY_MIR_SOCKET
95− initctl unset-env --global UNITY_MIR_SOCKET
9680 initctl unset-env --global MIR_SERVER_PROMPT_FILE
9781 initctl emit application-end
9882end script