-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathdiscord.sh
executable file
·48 lines (39 loc) · 1.42 KB
/
discord.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
44
45
46
47
48
#!/bin/bash
read -ra SOCAT_ARGS <<<"${SOCAT_ARGS}"
FLATPAK_ID=${FLATPAK_ID:-"com.discordapp.Discord"}
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
if [ -f "${XDG_CONFIG_HOME}/discord-flags.conf" ]
then
mapfile -t FLAGS <<< "$(grep -Ev '^\s*$|^#' "${XDG_CONFIG_HOME}/discord-flags.conf")"
fi
WAYLAND_SOCKET=${WAYLAND_DISPLAY:-"wayland-0"}
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/Discord --enable-speech-dispatcher "${FLAGS[@]}" "$@"
if [ "${invoke_socat}" = true ]
then
kill -SIGTERM "${socat_pid}"
fi