Last active
December 8, 2024 11:14
-
-
Save JoeBlakeB/9c60ae1b3a1904276580b12ac0ced018 to your computer and use it in GitHub Desktop.
Update the Discord build_info.json file so that you can still use it when there is a new version available.
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| # Copyright (C) 2022 Joe Baker (JoeBlakeB) | |
| # This program is free software under the GPLv3 license. | |
| # | |
| # This script is used to update the version number in the Discord | |
| # build_info.json file so that you do not need to manually update it, | |
| # or wait for the package maintainer to update it. | |
| # Discord will instead open normally and will not prompt you to update. | |
| # | |
| # Requirements: python3 and requests | |
| # and for you to have the following line in your sudoers file: | |
| # <username> ALL=(ALL) NOPASSWD: /usr/bin/tee /opt/discord/resources/build_info.json | |
| # | |
| # Usage: Change the Exec line in the discord.desktop file to run this script, for example: | |
| # Exec=/home/<user>/.local/bin/discordVersionUpdater.py && /usr/bin/discord | |
| import json | |
| import os | |
| import re | |
| import requests | |
| x = requests.head("https://discord.com/api/download/stable?platform=linux&format=tar.gz") | |
| versionNumber = x.headers["location"].split("/linux/")[1].split("/discord-")[0] | |
| if not re.match(r"^[0-9]+\.[0-9]+\.[0-9]+$", versionNumber): | |
| print("The version number is not valid") | |
| exit(1) | |
| currentVersion = json.loads(open("/opt/discord/resources/build_info.json").read())["version"] | |
| if currentVersion == versionNumber: | |
| exit(0) | |
| output = json.dumps({ | |
| "releaseChannel": "stable", | |
| "version": versionNumber}) | |
| os.system("echo '" + output + "' | sudo /usr/bin/tee /opt/discord/resources/build_info.json") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment