From c42feec312a6d959b971a76937a24d4cf1348eb5 Mon Sep 17 00:00:00 2001 From: zach Date: Sun, 16 Aug 2026 12:50:39 +0200 Subject: [PATCH] clean up code in updates singleton and popout --- Helpers/Updates.qml | 49 +++++---------------------- Modules/Bar/Popouts/UpdatesPopout.qml | 2 -- 2 files changed, 8 insertions(+), 43 deletions(-) diff --git a/Helpers/Updates.qml b/Helpers/Updates.qml index 9281ec7..cc1eb02 100644 --- a/Helpers/Updates.qml +++ b/Helpers/Updates.qml @@ -11,8 +11,8 @@ Singleton { id: root property int availableUpdates: 0 - property string cmd: "" property bool commandReady + property bool hasHelper property bool loaded property double now: Date.now() property var updates: ({}) @@ -38,18 +38,12 @@ Singleton { } function performPackageUpdate(pkg: string): void { - if (root.cmd === "pacman") - pkgUpdateProc.command = ["pkexec", root.cmd, "--noconfirm", "-Sy", pkg]; - else - pkgUpdateProc.command = [root.cmd, "--noconfirm", "--sudo", "pkexec", "-Sy", pkg]; + pkgUpdateProc.command = ["pkexec", "pacman", "--noconfirm", "-Sy", pkg]; pkgUpdateProc.running = true; } function performSystemUpdate(): void { - if (root.cmd === "pacman") - sysUpdateProc.command = ["pkexec", root.cmd, "--noconfirm", "-Syu"]; - else - sysUpdateProc.command = [root.cmd, "--noconfirm", "--sudo", "pkexec", "-Syu"]; + sysUpdateProc.command = ["pkexec", "pacman", "--noconfirm", "-Syu"]; sysUpdateProc.running = true; } @@ -87,7 +81,7 @@ Singleton { Process { id: cmdDetect - command: ["sh", "-c", "command -v checkupdates || command -v yay || command -v paru"] + command: ["sh", "-c", "command -v checkupdates"] running: true stdout: StdioCollector { @@ -96,47 +90,20 @@ Singleton { let helper; if (cmd.length > 0) { - helper = cmd.split("/").pop(); + helper = true; } else { - helper = "pacman"; - } - - if (helper === "checkupdates") { - updatesProc.command = [helper]; - } else { - updatesProc.command = [helper, "-Qu"]; + helper = false; } + root.hasHelper = helper; root.commandReady = true; } } } - Process { - id: updateCmdDetect - - command: ["sh", "-c", "command -v yay || command -v paru"] - running: true - - stdout: StdioCollector { - onStreamFinished: { - const cmd = this.text.trim(); - let helper; - - if (cmd.length > 0) { - helper = cmd.split("/").pop(); - } else { - helper = "pacman"; - } - - root.cmd = helper; - } - } - } - Process { id: updatesProc - command: [] + command: root.hasHelper ? ["checkupdates"] : [] running: false stdout: StdioCollector { diff --git a/Modules/Bar/Popouts/UpdatesPopout.qml b/Modules/Bar/Popouts/UpdatesPopout.qml index a7aef14..b88b107 100644 --- a/Modules/Bar/Popouts/UpdatesPopout.qml +++ b/Modules/Bar/Popouts/UpdatesPopout.qml @@ -78,8 +78,6 @@ CustomClippingRect { required property var modelData readonly property list sections: modelData.update.split(" ") - // anchors.left: parent.left - // anchors.right: parent.right color: Colors.tPalette.m3surfaceContainer implicitHeight: root.itemHeight implicitWidth: 600