forked from fathyb/carbonyl
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·58 lines (49 loc) · 1.92 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
executable file
·58 lines (49 loc) · 1.92 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
# Container entrypoint for the Carbonyl runtime image (#132, ADR-004).
#
# Sets container-safe terminal env, normalizes the --zoom flag, and execs the
# installed /usr/bin/carbonyl launcher (from the .deb) under tini. The terminal
# env, dbus-disable, shell-mode, and zoom-normalization approach is adapted from
# the community PR jmagly/carbonyl#1 by @eSlider; re-pointed at the .deb launcher.
set -eu
export TERM="${TERM:-xterm-256color}"
export LANG="${LANG:-C.UTF-8}"
export COLORTERM="${COLORTERM:-truecolor}"
# Containers usually have no system dbus; silence connection spam on stderr.
export DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-disabled:}"
# Skip the Rust PTY re-exec wrapper; we already run under tini in a container.
export CARBONYL_ENV_SHELL_MODE="${CARBONYL_ENV_SHELL_MODE:-1}"
# Release runtimes through ~alpha.9 apply an internal 1.5x zoom (pre-#100), so a
# default --zoom=67 yields ~100% effective zoom. Carbonyl accepts only the equals
# form (--zoom=N / -z=N); normalize space-separated "-z 50" / "--zoom 50" here so
# the value isn't mistaken for a URL. Set CARBONYL_ZOOM=100 once runtimes ship
# without the 1.5x multiplier.
ZOOM_PERCENT=""
ARGS_FILE="$(mktemp)"
trap 'rm -f "$ARGS_FILE"' EXIT INT TERM
: > "$ARGS_FILE"
while [ $# -gt 0 ]; do
case "$1" in
-z|--zoom)
shift
[ $# -gt 0 ] || { echo "carbonyl: --zoom requires a value (use --zoom=50 or -z 50)" >&2; exit 2; }
ZOOM_PERCENT="$1"; shift ;;
-z=*|--zoom=*)
ZOOM_PERCENT="${1#*=}"; shift ;;
*)
printf '%s\n' "$1" >> "$ARGS_FILE"; shift ;;
esac
done
[ -n "$ZOOM_PERCENT" ] || ZOOM_PERCENT="${CARBONYL_ZOOM:-67}"
set --
while IFS= read -r arg; do
[ -n "$arg" ] || continue
set -- "$@" "$arg"
done < "$ARGS_FILE"
exec /usr/bin/carbonyl \
--no-sandbox \
--disable-dev-shm-usage \
--disable-gpu \
--user-data-dir="${CARBONYL_DATA_DIR:-/home/carbonyl/profile}" \
--zoom="${ZOOM_PERCENT}" \
"$@"