-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdiscord-canary.sh
executable file
·43 lines (36 loc) · 1.32 KB
/
discord-canary.sh
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
#!/bin/bash
read -ra SOCAT_ARGS <<<"${SOCAT_ARGS}"
FLATPAK_ID=${FLATPAK_ID:-"com.discordapp.DiscordCanary"}
OUR_SOCKET="${XDG_RUNTIME_DIR}/app/${FLATPAK_ID}/discord-ipc-0"
DISCORD_SOCKET="${XDG_RUNTIME_DIR}/discord-ipc-0"
invoke_socat=true
# Check if our socket already exists.
if [ -S "${OUR_SOCKET}" ]
then
# Check if socat is listening on it.
if socat "${SOCAT_ARGS[@]}" -u OPEN:/dev/null "UNIX-CONNECT:${OUR_SOCKET}"
then
# socat is still listening on it, make sure not not invoke it again.
invoke_socat=false
else
# Socket exists but socat is not listening on it (for whatever reason), delete it so we can invoke socat again.
rm -f "${OUR_SOCKET}"
fi
fi
if [ "${invoke_socat}" = true ]
then
socat "${SOCAT_ARGS[@]}" "UNIX-LISTEN:${OUR_SOCKET},forever,fork" "UNIX-CONNECT:${DISCORD_SOCKET}" &
socat_pid=$!
fi
WAYLAND_SOCKET=${WAYLAND_DISPLAY:-"wayland-0"}
FLAGS=("${DISCORD_FLAGS[@]}" "--enable-speech-dispatcher")
if [[ -e "$XDG_RUNTIME_DIR/${WAYLAND_SOCKET}" || -e "${WAYLAND_DISPLAY}" ]]
then
FLAGS+=("--enable-features=WaylandWindowDecorations" "--ozone-platform-hint=auto")
fi
disable-breaking-updates.py
env TMPDIR="${XDG_CACHE_HOME}" zypak-wrapper /app/discord-canary/DiscordCanary "${FLAGS[@]}" "$@"
if [ "${invoke_socat}" = true ]
then
kill -SIGTERM "${socat_pid}"
fi