blob: 483ea84d7b4d63e03d98f939f12378dc21cb65c3 (
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
|
#!/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
}
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})"; }
[[ "${XDG_SESSION_TYPE}" == "wayland" ]] && {
unset DISPLAY
in_array CODE_USER_FLAGS '^--ozone-platform=wayland$' \
|| CODE_USER_FLAGS+=('--ozone-platform=wayland')
in_array CODE_USER_FLAGS '^--enable-features=.*UseOzonePlatform' \
|| CODE_USER_FLAGS+=('--enable-features=UseOzonePlatform')
}
exec "${CODE_BIN_PATH}" "${CODE_USER_FLAGS[@]}" "$@"
exit 0
}
main "$@"
|