blob: 5c3d2b877a020170da2851294c89344767dda44e (
plain)
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
59
60
61
|
#!/usr/bin/env bash
shopt -s nocasematch
declare -r CODE_BIN_PATH="/opt/code-translucent/bin/code-oss"
declare -r XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
declare -r CODE_CONF_PATH="${XDG_CONFIG_HOME}/code-flags.conf"
in_array() {
local -n array=$1
local -r pattern=$2
for value in "${array[@]}"; do
[[ "${value}" =~ $pattern ]] \
&& return 0
done
return 1
}
is_wayland() {
[[ "${XDG_SESSION_TYPE}" == "wayland" ]] \
&& return 0
[[ -n "${WAYLAND_DISPLAY}" ]] \
&& return 0
return 1
}
main() {
local -a CODE_USER_FLAGS=()
[[ -e "${CODE_BIN_PATH}" ]] \
|| { echo "'${CODE_BIN_PATH}' does not exist?!"; exit 1; }
[[ -f "${CODE_CONF_PATH}" ]] \
&& { mapfile -t CODE_USER_FLAGS <<< "$(sed 's/#.*//' ${CODE_CONF_PATH})"; }
is_wayland && {
in_array CODE_USER_FLAGS '^--ozone-platform-hint=auto$' \
|| CODE_USER_FLAGS+=('--ozone-platform-hint=auto')
in_array CODE_USER_FLAGS '^--enable-features=.*WaylandWindowDecorations' \
|| CODE_USER_FLAGS+=('--enable-features=WaylandWindowDecorations')
}
exec "${CODE_BIN_PATH}" "$@" "${CODE_USER_FLAGS[@]}"
exit 0
}
main "$@"
|