aboutsummaryrefslogtreecommitdiff
path: root/.local/share/bin/installbd
blob: ae17002b85a4d5e51372d837d22d3a33dadd9cb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh
discord_path="$(dirname "$(find "$XDG_CONFIG_HOME/discord" -name core.asar)")"
discord_version="$(echo "$discord_path" | tr '/' '\n' | tac | sed -n '/^[0-9.]\+$/p' | head -n1)"
betterdiscord_path="$XDG_CONFIG_HOME/BetterDiscord/data/betterdiscord.asar"
cache_file="$XDG_CACHE_HOME/bdversion"

if [ "$discord_path" -nt "$betterdiscord_path" ] ; then
	echo "download betterdiscord.asar"
	curl -sLo - 'https://betterdiscord.app/Download/betterdiscord.asar' > "$betterdiscord_path"
fi
if ! grep "$(basename "$betterdiscord_path")" "$discord_path/index.js" > /dev/null ; then
	echo "patch discord desktop core index.js"
	printf 'require("%s");\n%s' "$betterdiscord_path" "$(cat "$discord_path/index.js")" > "$discord_path/index.js"
fi

# store discord version used for this install
mkdir -p "$(dirname "$cache_file")"
echo "$discord_version" > "$cache_file"

echo "done!"