blob: 5e0bd1d154583ba0cec957b6b3b413edffb8b90d (
plain) (
blame)
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
|
#!/bin/sh
set -e
SWAY_BIN=${SWAY_BIN:-/usr/bin/sway}
SWAY_ARGS=${SWAY_ARGS:-}
SWAY_USER=${SWAY_USER:-robert}
sway_user_id=$(id -u "${SWAY_USER}")
SWAY_TTY=${SWAY_TTY:-7}
MANUAL=
export XDG_RUNTIME_DIR=/run/user/"${sway_user_id}"
source /home/"${SWAY_USER}"/.config/sway/env
while getopts ":dcDmh" o; do
case $o in
d) SWAY_ARGS="$SWAY_ARGS --debug" ;;
D)
export XDG_RUNTIME_DIR=/tmp/sway-run-debug
[ ! -d "${XDG_RUNTIME_DIR}" ] && mkdir "${XDG_RUNTIME_DIR}" && chmod 700 "${XDG_RUNTIME_DIR}"
;;
c) SWAY_ARGS="${SWAY_ARGS} --config /home/${SWAY_USER}/.config/sway/simple.conf --debug" ;;
m) MANUAL=1 ;;
h) echo "usage: $0 [-dcDLh]"; exit 0 ;;
*) echo "unknown flag: $o" 1>&2
esac
done
shift $((OPTIND-1))
ts="$(date -u --rfc-3339=seconds | tr ' ' 'T')"
log=/var/log/sway/${ts}.log
if [ -n "${MANUAL}" ]; then
cat <<EOF | doas sh -s
# prepare tty
chown "$SWAY_USER" "/dev/tty${SWAY_TTY}"
chmod 600 "/dev/tty${SWAY_TTY}"
# launch sway on new tty
su --preserve-environment --login --command \
"openvt --switch --console ${SWAY_TTY} -- dbus-run-session ${SWAY_BIN} -Ddamage=rerender ${SWAY_ARGS} 1>&2 2>${log}" \
"${SWAY_USER}"
EOF
else
exec dbus-run-session "${SWAY_BIN}" -Ddamage=rerender ${SWAY_ARGS} $@ 1>&2 2>"${log}"
# exec "${SWAY_BIN}" -Ddamage=rerender ${SWAY_ARGS} $@ 1>&2 2>"${log}"
fi
|