commit a6da00a718680698b607be9025e7ebd2d4b4eaa2
Author: Valentin Tainon <valentin.tainon(a)outlook.fr>
Date: Sun Apr 21 19:03:23 2024 +0200
added disable-breaking-updates.py, wrapper.sh and edited discord.spec
Signed-off-by: Nicolas Chauvet <kwizart(a)gmail.com>
disable-breaking-updates.py | 40 ++++++++++++++++++++++++++++++++++++++++
discord.spec | 6 +++++-
wrapper.sh | 10 ++++++++++
3 files changed, 55 insertions(+), 1 deletion(-)
---
diff --git a/disable-breaking-updates.py b/disable-breaking-updates.py
new file mode 100755
index 0000000..1b5364a
--- /dev/null
+++ b/disable-breaking-updates.py
@@ -0,0 +1,40 @@
+#!/usr/bin/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")
diff --git a/discord.spec b/discord.spec
index 8573acf..1a78b59 100644
--- a/discord.spec
+++ b/discord.spec
@@ -16,6 +16,8 @@ URL:
https://discordapp.com/
Source0:
https://dl.discordapp.net/apps/linux/%{version}/%{name}-%{version}.tar.gz
# Adapted from
https://raw.githubusercontent.com/flathub/com.discordapp.Discord/master/c...
Source1: discord.metainfo.xml
+Source2: wrapper.sh
+Source3: disable-breaking-updates.py
ExclusiveArch: x86_64
BuildRequires: desktop-file-utils
@@ -56,7 +58,7 @@ mkdir -p %{buildroot}%{_metainfodir}/
desktop-file-install \
--set-icon=%{name} \
---set-key=Exec --set-value=%{_bindir}/Discord \
+--set-key=Exec --set-value='%{_libdir}/discord/wrapper.sh' \
--delete-original \
--dir=%{buildroot}/%{_datadir}/applications \
discord.desktop
@@ -67,6 +69,8 @@ install -p -D -m 644 %{name}.png \
%{buildroot}%{_datadir}/icons/hicolor/256x256/apps/%{name}.png
install -p -m 0644 %{SOURCE1} %{buildroot}%{_metainfodir}/
+install -p -m 755 %{SOURCE2} %{buildroot}%{_libdir}/discord/
+install -p -m 755 %{SOURCE3} %{buildroot}%{_libdir}/discord/
%check
desktop-file-validate %{buildroot}/%{_datadir}/applications/%{name}.desktop
diff --git a/wrapper.sh b/wrapper.sh
new file mode 100755
index 0000000..63e16ee
--- /dev/null
+++ b/wrapper.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/bash
+
+# Path to discord binary
+DISCORD_BIN=/usr/bin/Discord
+
+# Run python script to disable check updates
+/usr/lib64/discord/disable-breaking-updates.py
+
+# Launch discord
+exec "$DISCORD_BIN"