about summary refs log tree commit diff
path: root/pkgs/applications/networking/instant-messengers/discord/disable-breaking-updates.py
diff options
context:
space:
mode:
authorArtturi <Artturin@artturin.com>2022-10-22 21:50:39 +0300
committerGitHub <noreply@github.com>2022-10-22 14:50:39 -0400
commitcdde640978b59004fb5ad91a66ba95a4ae52d770 (patch)
tree82b10836b93c78b0fbb8660b46f532db07646189 /pkgs/applications/networking/instant-messengers/discord/disable-breaking-updates.py
parent655b51eb188a5abe9748796888226b68e988dc2f (diff)
discord: add a script to disable breaking updates (#197248)
Diffstat (limited to 'pkgs/applications/networking/instant-messengers/discord/disable-breaking-updates.py')
-rw-r--r--pkgs/applications/networking/instant-messengers/discord/disable-breaking-updates.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/pkgs/applications/networking/instant-messengers/discord/disable-breaking-updates.py b/pkgs/applications/networking/instant-messengers/discord/disable-breaking-updates.py
new file mode 100644
index 0000000000000..a7217d0ad6e0c
--- /dev/null
+++ b/pkgs/applications/networking/instant-messengers/discord/disable-breaking-updates.py
@@ -0,0 +1,42 @@
+#!@pythonInterpreter@
+# slightly tweaked from the script created by @lionirdeadman
+# https://github.com/flathub/com.discordapp.Discord/blob/master/disable-breaking-updates.py
+"""
+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}/@configDirName@/settings.json")
+settings_path_temp = Path(f"{XDG_CONFIG_HOME}/@configDirName@/settings.json.tmp")
+try:
+    with settings_path.open(encoding="utf-8") as settings_file:
+        settings = json.load(settings_file)
+
+        if settings.get("SKIP_HOST_UPDATE"):
+            print("[Nix] Disabling updates already done")
+        else:
+            skip_host_update = {"SKIP_HOST_UPDATE": True}
+            settings.update(skip_host_update)
+
+            with settings_path_temp.open("w", encoding="utf-8") as settings_file_temp:
+                json.dump(settings, settings_file_temp, indent=2)
+
+            settings_path_temp.rename(settings_path)
+            print("[Nix] Disabled updates")
+
+except IOError:
+    print("[Nix] settings.json doesn't yet exist, can't disable it yet")