From 0a892a4a9ecc844edc62cba5ed947e5b9e6226fe Mon Sep 17 00:00:00 2001 From: purian23 Date: Thu, 14 May 2026 20:32:42 -0400 Subject: [PATCH] refactor(SysUpdate): Explicit Run on Startup option in settings - Relocated DMS System Updater to System Setting section - Removed forced auto refresh upon update & widget loading --- core/internal/server/sysupdate/manager.go | 8 +--- quickshell/Common/SettingsData.qml | 1 + quickshell/Common/settings/SettingsSpec.js | 1 + .../Modals/Settings/SettingsSidebar.qml | 14 +++---- .../DankBar/Popouts/SystemUpdatePopout.qml | 10 ----- .../Modules/Settings/SystemUpdaterTab.qml | 7 ++++ quickshell/Services/SystemUpdateService.qml | 40 ++++++++++++++++++- 7 files changed, 55 insertions(+), 26 deletions(-) diff --git a/core/internal/server/sysupdate/manager.go b/core/internal/server/sysupdate/manager.go index e18dbfe3..f1c8cb80 100644 --- a/core/internal/server/sysupdate/manager.go +++ b/core/internal/server/sysupdate/manager.go @@ -79,8 +79,6 @@ func NewManager() (*Manager, error) { m.schedulerWG.Add(1) go m.scheduler() - go m.runRefresh(context.Background()) - return m, nil } @@ -183,14 +181,11 @@ func (m *Manager) Cancel() { } func (m *Manager) Acquire() { - first := atomic.AddInt32(&m.acquireCount, 1) == 1 + atomic.AddInt32(&m.acquireCount, 1) select { case m.wakeSched <- struct{}{}: default: } - if first { - go m.runRefresh(context.Background()) - } } func (m *Manager) Release() { @@ -415,7 +410,6 @@ func (m *Manager) finishSuccessfulUpgrade(clearPackages bool) { } m.mu.Unlock() m.markDirty() - go m.runRefresh(context.Background()) } func upgradeBackends(sel Selection, opts UpgradeOptions) []Backend { diff --git a/quickshell/Common/SettingsData.qml b/quickshell/Common/SettingsData.qml index 58a7597e..f6037b2e 100644 --- a/quickshell/Common/SettingsData.qml +++ b/quickshell/Common/SettingsData.qml @@ -720,6 +720,7 @@ Singleton { property string customPowerActionPowerOff: "" property bool updaterHideWidget: false + property bool updaterCheckOnStart: false property bool updaterUseCustomCommand: false property string updaterCustomCommand: "" property string updaterTerminalAdditionalParams: "" diff --git a/quickshell/Common/settings/SettingsSpec.js b/quickshell/Common/settings/SettingsSpec.js index a55c3e4b..340b5d78 100644 --- a/quickshell/Common/settings/SettingsSpec.js +++ b/quickshell/Common/settings/SettingsSpec.js @@ -431,6 +431,7 @@ var SPEC = { customPowerActionPowerOff: { def: "" }, updaterHideWidget: { def: false }, + updaterCheckOnStart: { def: false }, updaterUseCustomCommand: { def: false }, updaterCustomCommand: { def: "" }, updaterTerminalAdditionalParams: { def: "" }, diff --git a/quickshell/Modals/Settings/SettingsSidebar.qml b/quickshell/Modals/Settings/SettingsSidebar.qml index 4c01b9cd..ee8c0d6b 100644 --- a/quickshell/Modals/Settings/SettingsSidebar.qml +++ b/quickshell/Modals/Settings/SettingsSidebar.qml @@ -159,13 +159,6 @@ Rectangle { "icon": "tune", "tabIndex": 18 }, - { - "id": "updater", - "text": I18n.tr("System Updater"), - "icon": "refresh", - "tabIndex": 20, - "updaterOnly": true - }, { "id": "desktop_widgets", "text": I18n.tr("Desktop Widgets"), @@ -293,6 +286,13 @@ Rectangle { "icon": "terminal", "tabIndex": 32 }, + { + "id": "updater", + "text": I18n.tr("System Updater"), + "icon": "refresh", + "tabIndex": 20, + "updaterOnly": true + }, { "id": "window_rules", "text": I18n.tr("Window Rules"), diff --git a/quickshell/Modules/DankBar/Popouts/SystemUpdatePopout.qml b/quickshell/Modules/DankBar/Popouts/SystemUpdatePopout.qml index 584a8d70..faf67fc0 100644 --- a/quickshell/Modules/DankBar/Popouts/SystemUpdatePopout.qml +++ b/quickshell/Modules/DankBar/Popouts/SystemUpdatePopout.qml @@ -75,16 +75,6 @@ DankPopout { close(); } - onShouldBeVisibleChanged: { - if (!shouldBeVisible) { - return; - } - const stale = !SystemUpdateService.lastCheckUnix || (Date.now() / 1000 - SystemUpdateService.lastCheckUnix) > 300; - if (stale && !SystemUpdateService.isChecking && !SystemUpdateService.isUpgrading) { - SystemUpdateService.checkForUpdates(); - } - } - content: Component { Rectangle { id: updaterPanel diff --git a/quickshell/Modules/Settings/SystemUpdaterTab.qml b/quickshell/Modules/Settings/SystemUpdaterTab.qml index 1f98744e..c2c3376b 100644 --- a/quickshell/Modules/Settings/SystemUpdaterTab.qml +++ b/quickshell/Modules/Settings/SystemUpdaterTab.qml @@ -93,6 +93,13 @@ Item { } } + SettingsToggleRow { + text: I18n.tr("Check on startup") + description: I18n.tr("When enabled, checks updates on startup. When disabled, only the interval above or a manual refresh runs a check.") + checked: SettingsData.updaterCheckOnStart + onToggled: checked => SettingsData.set("updaterCheckOnStart", checked) + } + SettingsToggleRow { text: I18n.tr("Include Flatpak updates") description: I18n.tr("Apply Flatpak updates alongside system updates when running 'Update All'.") diff --git a/quickshell/Services/SystemUpdateService.qml b/quickshell/Services/SystemUpdateService.qml index ab1603aa..2af4bd43 100644 --- a/quickshell/Services/SystemUpdateService.qml +++ b/quickshell/Services/SystemUpdateService.qml @@ -43,22 +43,36 @@ Singleton { root.checkCapabilities(); } else { root.sysupdateAvailable = false; + root._startupCheckDone = false; } + Qt.callLater(() => root._maybeStartupCheck()); } function onSysupdateStateUpdate(data) { root._applyState(data); } } + Connections { + target: SettingsData + function onUpdaterCheckOnStartChanged() { + Qt.callLater(() => root._maybeStartupCheck()); + } + function on_HasLoadedChanged() { + Qt.callLater(() => root._maybeStartupCheck()); + } + } + Component.onCompleted: { if (DMSService.dmsAvailable) { checkCapabilities(); } + Qt.callLater(() => root._maybeStartupCheck()); } function checkCapabilities() { if (!DMSService.capabilities || !Array.isArray(DMSService.capabilities)) { sysupdateAvailable = false; + Qt.callLater(() => root._maybeStartupCheck()); return; } const has = DMSService.capabilities.includes("sysupdate"); @@ -68,6 +82,7 @@ Singleton { } else if (!has) { sysupdateAvailable = false; } + Qt.callLater(() => root._maybeStartupCheck()); } function requestState() { @@ -171,10 +186,31 @@ Singleton { Process { id: customRunner - onExited: root.checkForUpdates() } - onRefCountChanged: _syncAcquire() + property bool _startupCheckDone: false + + function _maybeStartupCheck() { + if (refCount <= 0) { + _startupCheckDone = false; + return; + } + if (!SettingsData.updaterCheckOnStart) + return; + if (_startupCheckDone) + return; + if (!DMSService.isConnected || !sysupdateAvailable) + return; + _startupCheckDone = true; + Qt.callLater(() => root.checkForUpdates()); + } + + onRefCountChanged: { + if (refCount <= 0) + _startupCheckDone = false; + _syncAcquire(); + Qt.callLater(() => root._maybeStartupCheck()); + } onSysupdateAvailableChanged: _syncAcquire() property bool _acquired: false