From 50035ee2f2ab513c29acb6a482cc3de8beadcc4e Mon Sep 17 00:00:00 2001
From: Luca Bilke <bilke@tralios.de>
Date: Mon, 17 Jul 2023 13:49:34 +0200
Subject: [PATCH] only update user.js if there is a new arkenfox

---
 .local/bin/upgrades | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/.local/bin/upgrades b/.local/bin/upgrades
index 0d762d8f..ca1236da 100755
--- a/.local/bin/upgrades
+++ b/.local/bin/upgrades
@@ -18,8 +18,14 @@ command -v apt 1>/dev/null 2>&1 && sudo apt upgrade
 
 command -v xbps-install 1>/dev/null 2>&1 && sudo xbps-install -Syu && pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
 
-printf "%b" "$BOLD${BLUE}Updating arkenfox...$NC\n"
-"$DOTS_DIR/.local/share/firefox/updater.sh" -b
+
+newversion=$(grep -oP '(?<=\* version: )\d\d\d' "$(DISPLAY=invalid "$DOTS_DIR"/.local/share/firefox/updater.sh -r 2>/dev/null | grep -oP '(?<=Warning: user.js was saved to temporary file )/tmp/tmp\.\w+\.js')")
+oldversion=$(grep -oP '(?<=\* version: )\d\d\d' "$DOTS_DIR"/.local/share/firefox/user.js)
+
+if [ $newversion -gt $oldversion ]; then
+    printf "%b" "$BOLD${BLUE}Updating arkenfox...$NC\n"
+    "$DOTS_DIR/.local/share/firefox/updater.sh" -b
+fi
 
 printf "%b" "$BOLD${BLUE}Upgrade complete.\nPress <Enter> to exit window.\n"
 read -r _