2 # slightly tweaked from the script created by @lionirdeadman
3 # https://github.com/flathub/com.discordapp.Discord/blob/master/disable-breaking-updates.py
5 Disable breaking updates which will prompt users to download a deb or tar file
6 and lock them out of Discord making the program unusable.
8 This will dramatically improve the experience :
10 1) The maintainer doesn't need to be worried at all times of an update which will break Discord.
11 2) People will not be locked out of the program while the maintainer runs to update it.
18 from pathlib
import Path
21 "darwin": os
.path
.join(os
.path
.expanduser("~"), "Library", "Application Support"),
22 "linux": os
.environ
.get("XDG_CONFIG_HOME") or os
.path
.join(os
.path
.expanduser("~"), ".config")
23 }.get(sys
.platform
, None)
25 if config_home
is None:
26 print("[Nix] Unsupported operating system.")
29 config_dir_name
= "@configDirName@".replace(" ", "") if sys
.platform
== "darwin" else "@configDirName@"
31 settings_path
= Path(f
"{config_home}/{config_dir_name}/settings.json")
32 settings_path_temp
= Path(f
"{config_home}/{config_dir_name}/settings.json.tmp")
34 if os
.path
.exists(settings_path
):
35 with settings_path
.open(encoding
="utf-8") as settings_file
:
37 settings
= json
.load(settings_file
)
38 except json
.JSONDecodeError
:
39 print("[Nix] settings.json is malformed, letting Discord fix itself")
44 if settings
.get("SKIP_HOST_UPDATE"):
45 print("[Nix] Disabling updates already done")
47 skip_host_update
= {"SKIP_HOST_UPDATE": True}
48 settings
.update(skip_host_update
)
50 os
.makedirs(os
.path
.dirname(settings_path
), exist_ok
=True)
52 with settings_path_temp
.open("w", encoding
="utf-8") as settings_file_temp
:
53 json
.dump(settings
, settings_file_temp
, indent
=2)
55 settings_path_temp
.rename(settings_path
)
56 print("[Nix] Disabled updates")