mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-02 03:28:28 -04:00
sysupdate: pass custom command to daemon instead of fire and forget from
QML
related #2873
port 1.5
(cherry picked from commit 0ffec5011b)
This commit is contained in:
@@ -74,7 +74,7 @@ DankPopout {
|
||||
color: "transparent"
|
||||
focus: true
|
||||
|
||||
readonly property bool hasTerminalBackend: (SystemUpdateService.backends || []).some(b => b.runsInTerminal === true)
|
||||
readonly property bool upgradeRunsInTerminal: SystemUpdateService.useCustomCommand || (SystemUpdateService.backends || []).some(b => b.runsInTerminal === true)
|
||||
|
||||
property int nowUnix: Math.floor(Date.now() / 1000)
|
||||
|
||||
@@ -272,7 +272,7 @@ DankPopout {
|
||||
includeAUR: SettingsData.updaterAllowAUR,
|
||||
terminal: SessionData.terminalOverride
|
||||
};
|
||||
if (updaterPanel.hasTerminalBackend) {
|
||||
if (updaterPanel.upgradeRunsInTerminal) {
|
||||
systemUpdatePopout._reopenAfterUpgrade = true;
|
||||
SystemUpdateService.runUpdates(opts);
|
||||
systemUpdatePopout.close();
|
||||
@@ -478,7 +478,7 @@ DankPopout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingM
|
||||
spacing: Theme.spacingS
|
||||
visible: SystemUpdateService.isUpgrading && updaterPanel.hasTerminalBackend
|
||||
visible: SystemUpdateService.isUpgrading && updaterPanel.upgradeRunsInTerminal
|
||||
|
||||
DankIcon {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
@@ -509,7 +509,7 @@ DankPopout {
|
||||
DankFlickable {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingM
|
||||
visible: SystemUpdateService.isUpgrading && !updaterPanel.hasTerminalBackend
|
||||
visible: SystemUpdateService.isUpgrading && !updaterPanel.upgradeRunsInTerminal
|
||||
contentWidth: width
|
||||
contentHeight: logText.implicitHeight
|
||||
clip: true
|
||||
|
||||
@@ -3,7 +3,6 @@ pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
|
||||
@@ -34,6 +33,7 @@ Singleton {
|
||||
|
||||
readonly property int updateCount: availableUpdates.length
|
||||
readonly property bool helperAvailable: sysupdateAvailable && backends.length > 0
|
||||
readonly property bool useCustomCommand: SettingsData.updaterUseCustomCommand && (SettingsData.updaterCustomCommand || "").trim().length > 0
|
||||
|
||||
Connections {
|
||||
target: DMSService
|
||||
@@ -183,11 +183,14 @@ Singleton {
|
||||
|
||||
function runUpdates(opts) {
|
||||
const params = opts || {};
|
||||
if (SettingsData.updaterUseCustomCommand && SettingsData.updaterCustomCommand.length > 0) {
|
||||
_runCustomTerminalCommand();
|
||||
return;
|
||||
}
|
||||
params.ignored = SettingsData.updaterIgnoredPackages || [];
|
||||
if (useCustomCommand) {
|
||||
params.customCommand = SettingsData.updaterCustomCommand.trim();
|
||||
const termArgs = (SettingsData.updaterTerminalAdditionalParams || "").trim();
|
||||
if (termArgs.length > 0) {
|
||||
params.terminalArgs = termArgs.split(/\s+/);
|
||||
}
|
||||
}
|
||||
DMSService.sysupdateUpgrade(params, null);
|
||||
}
|
||||
|
||||
@@ -199,30 +202,6 @@ Singleton {
|
||||
DMSService.sysupdateSetInterval(seconds, null);
|
||||
}
|
||||
|
||||
function _runCustomTerminalCommand() {
|
||||
const terminal = SessionData.resolveTerminal();
|
||||
if (!terminal || terminal.length === 0) {
|
||||
ToastService.showError(I18n.tr("No terminal configured"), I18n.tr("Pick a terminal in Settings → Launcher (or set $TERMINAL)."));
|
||||
return;
|
||||
}
|
||||
const updateCommand = `${SettingsData.updaterCustomCommand} && echo -n "Updates complete! " ; echo "Press Enter to close..." && read`;
|
||||
const termClass = SettingsData.updaterTerminalAdditionalParams || "";
|
||||
var argv = [terminal];
|
||||
if (termClass.length > 0) {
|
||||
argv = argv.concat(termClass.split(" "));
|
||||
}
|
||||
argv.push("-e");
|
||||
argv.push("sh");
|
||||
argv.push("-c");
|
||||
argv.push(updateCommand);
|
||||
customRunner.command = argv;
|
||||
customRunner.running = true;
|
||||
}
|
||||
|
||||
Process {
|
||||
id: customRunner
|
||||
}
|
||||
|
||||
property bool _startupCheckDone: false
|
||||
|
||||
function _maybeStartupCheck() {
|
||||
@@ -262,5 +241,4 @@ Singleton {
|
||||
}
|
||||
DMSService.sysupdateRelease(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user