-
Notifications
You must be signed in to change notification settings - Fork 0
/
discord-disable-breaking-updates.py
executable file
·40 lines (31 loc) · 1.27 KB
/
discord-disable-breaking-updates.py
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
#!/usr/bin/env python3
"""
Disable breaking updates which will prompt users to download a deb or tar file
and lock them out of Discord making the program unusable.
This will dramatically improve the experience :
1) The maintainer doesn't need to be worried at all times of an update which will break Discord.
2) People will not be locked out of the program while the maintainer runs to update it.
"""
import json
import os
from pathlib import Path
XDG_CONFIG_HOME = os.environ.get("XDG_CONFIG_HOME") or os.path.join(
os.path.expanduser("~"), ".config"
)
settings_path = Path(f"{XDG_CONFIG_HOME}/discord/settings.json")
settings_path_temp = Path(f"{XDG_CONFIG_HOME}/discord/settings.json.tmp")
try:
with settings_path.open() as settings_file:
settings = json.load(settings_file)
except (IOError, json.decoder.JSONDecodeError):
settings_path.parent.mkdir(parents=True, exist_ok=True)
settings = {}
if settings.get("SKIP_HOST_UPDATE"):
print("Disabling updates already done")
else:
skip_host_update = {"SKIP_HOST_UPDATE":True}
settings.update(skip_host_update)
with settings_path_temp.open('w') as settings_file_temp:
json.dump(settings, settings_file_temp, indent=2)
settings_path_temp.rename(settings_path)
print("Disabled updates")