#!/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!"