Created
February 21, 2022 12:22
-
-
Save franga2000/12e87b39707c25ad455f5425b2116626 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Discord will not launch if it detects it's outdated. | |
# Since packages sometimes take a day or two to get updated, this script will trick it into launching anyways. | |
# Of course, you should still install an update as soon as it0s available. | |
# | |
# This script requires: curl, jq | |
# optional: sudo or polkit | |
# | |
set -e | |
discord_dir="$(dirname "$(realpath "$(which discord)")")" | |
echo Detected discord dir: $discord_dir | |
if [[ ! -d "$discord_dir" ]]; then | |
echo "Invalid!" | |
exit -1 | |
fi | |
channel="$(jq -r .releaseChannel <$discord_dir/resources/build_info.json)" | |
current_version="$(jq -r .version <$discord_dir/resources/build_info.json)" | |
echo Current build: $channel @ $current_version | |
new_version=$(curl -s 'https://discord.com/api/updates/'$channel'?platform=linux' | jq -r .name) | |
echo Newest version is $new_version | |
if [[ "$current_version" = "$new_version" ]]; then | |
echo Version already newest! | |
exit 0 | |
fi | |
sudo="" | |
if [[ ! -w "$discord_dir/resources/build_info.json" ]]; then | |
echo Need elevated privileges to modify program files | |
if command -v pkexec &> /dev/null; then | |
sudo="pkexec" | |
else | |
sudo="sudo" | |
fi | |
fi | |
$sudo tee $discord_dir/resources/build_info.json <<EOF | |
{ | |
"releaseChannel": "$channel", | |
"version": "$new_version" | |
} | |
EOF | |
echo Version updated! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment