blob: e72fbaaac4b7bb0fc2ca8b7620855dc8bd5324f8 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001#!/bin/sh
2# Copyright (C) 2016 O.S. Systems Software LTDA.
3# Copyright (C) 2016 Freescale Semiconductor
4
5export PATH="/sbin:/usr/sbin:/bin:/usr/bin"
6
7usage() {
8 cat <<EOF
9 $0 [<openvt arguments>] [-- <weston options>]
10EOF
11}
12
13## Module support
14modules_dir=@DATADIR@/weston-start
15
16# Add weston extra argument
17add_weston_argument() {
18 weston_args="$weston_args $1"
19}
20
21# Add openvt extra argument
22add_openvt_argument() {
23 openvt_args="$openvt_args $1"
24}
25
26if [ -n "$WAYLAND_DISPLAY" ]; then
27 echo "ERROR: A Wayland compositor is already running, nested Weston instance is not supported yet."
28 exit 1
29fi
30if [ -n "$DISPLAY" ]; then
31 launcher="weston"
32else
33 launcher="weston-launch --"
34fi
35
36openvt_args="-s"
37while [ -n "$1" ]; do
38 if [ "$1" = "--" ]; then
39 shift
40 break
41 fi
42 openvt_args="$openvt_args $1"
43 shift
44done
45
46weston_args=$*
47
48# Load and run modules
49if [ -d "$modules_dir" ]; then
50 for m in "$modules_dir"/*; do
51 # Skip backup files
52 if [ "`echo $m | sed -e 's/\~$//'`" != "$m" ]; then
53 continue
54 fi
55
56 # process module
57 . $m
58 done
59fi
60
61if test -z "$XDG_RUNTIME_DIR"; then
62 export XDG_RUNTIME_DIR=/run/user/`id -u`
63 if ! test -d "$XDG_RUNTIME_DIR"; then
64 mkdir --parents $XDG_RUNTIME_DIR
65 chmod 0700 $XDG_RUNTIME_DIR
66 fi
67fi
68
69exec openvt $openvt_args -- $launcher $weston_args --log=@LOCALSTATEDIR@/log/weston.log