mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-10 07:25:37 -05:00
add support for system updates on fedora (#353)
This commit is contained in:
@@ -171,7 +171,7 @@ DankPopout {
|
|||||||
return "Failed to check for updates:\n" + SystemUpdateService.errorMessage;
|
return "Failed to check for updates:\n" + SystemUpdateService.errorMessage;
|
||||||
}
|
}
|
||||||
if (!SystemUpdateService.helperAvailable) {
|
if (!SystemUpdateService.helperAvailable) {
|
||||||
return "No package manager found. Please install 'paru' or 'yay' to check for updates.";
|
return "No package manager found. Please install 'paru' or 'yay' on Arch-based systems to check for updates.";
|
||||||
}
|
}
|
||||||
if (SystemUpdateService.isChecking) {
|
if (SystemUpdateService.isChecking) {
|
||||||
return "Checking for updates...";
|
return "Checking for updates...";
|
||||||
|
|||||||
@@ -19,7 +19,48 @@ Singleton {
|
|||||||
property bool distributionSupported: false
|
property bool distributionSupported: false
|
||||||
property string shellVersion: ""
|
property string shellVersion: ""
|
||||||
|
|
||||||
readonly property list<string> supportedDistributions: ["arch", "cachyos", "manjaro", "endeavouros"]
|
readonly property var archBasedSettings: {
|
||||||
|
"listUpdatesParams": ["-Qu"],
|
||||||
|
"upgradeSettings": {
|
||||||
|
"params": ["-Syu"],
|
||||||
|
"requiresSudo": false
|
||||||
|
},
|
||||||
|
"parserSettings": {
|
||||||
|
"lineRegex": /^(\S+)\s+([^\s]+)\s+->\s+([^\s]+)$/,
|
||||||
|
"entryProducer": function (match) {
|
||||||
|
return {
|
||||||
|
"name": match[1],
|
||||||
|
"currentVersion": match[2],
|
||||||
|
"newVersion": match[3],
|
||||||
|
"description": `${match[1]} ${match[2]} → ${match[3]}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property var packageManagerParams: {
|
||||||
|
"yay": archBasedSettings,
|
||||||
|
"paru": archBasedSettings,
|
||||||
|
"dnf": {
|
||||||
|
"listUpdatesParams": ["list", "--upgrades", "--quiet", "--color=never"],
|
||||||
|
"upgradeSettings": {
|
||||||
|
"params": ["upgrade"],
|
||||||
|
"requiresSudo": true
|
||||||
|
},
|
||||||
|
"parserSettings": {
|
||||||
|
"lineRegex": /^([^\s]+)\s+([^\s]+)\s+.*$/,
|
||||||
|
"entryProducer": function (match) {
|
||||||
|
return {
|
||||||
|
"name": match[1],
|
||||||
|
"currentVersion": "",
|
||||||
|
"newVersion": match[2],
|
||||||
|
"description": `${match[1]} → ${match[2]}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
readonly property list<string> supportedDistributions: ["arch", "cachyos", "manjaro", "endeavouros", "fedora"]
|
||||||
readonly property int updateCount: availableUpdates.length
|
readonly property int updateCount: availableUpdates.length
|
||||||
readonly property bool helperAvailable: pkgManager !== "" && distributionSupported
|
readonly property bool helperAvailable: pkgManager !== "" && distributionSupported
|
||||||
|
|
||||||
@@ -63,7 +104,7 @@ Singleton {
|
|||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: helperDetection
|
id: helperDetection
|
||||||
command: ["sh", "-c", "which paru || which yay"]
|
command: ["sh", "-c", "which paru || which yay || which dnf"]
|
||||||
|
|
||||||
onExited: (exitCode) => {
|
onExited: (exitCode) => {
|
||||||
if (exitCode === 0) {
|
if (exitCode === 0) {
|
||||||
@@ -110,7 +151,7 @@ Singleton {
|
|||||||
|
|
||||||
isChecking = true
|
isChecking = true
|
||||||
hasError = false
|
hasError = false
|
||||||
updateChecker.command = [pkgManager, "-Qu"]
|
updateChecker.command = [pkgManager].concat(packageManagerParams[pkgManager].listUpdatesParams)
|
||||||
updateChecker.running = true
|
updateChecker.running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,15 +159,13 @@ Singleton {
|
|||||||
const lines = output.trim().split('\n').filter(line => line.trim())
|
const lines = output.trim().split('\n').filter(line => line.trim())
|
||||||
const updates = []
|
const updates = []
|
||||||
|
|
||||||
|
const regex = packageManagerParams[pkgManager].parserSettings.lineRegex
|
||||||
|
const entryProducer = packageManagerParams[pkgManager].parserSettings.entryProducer
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
const match = line.match(/^(\S+)\s+([^\s]+)\s+->\s+([^\s]+)$/)
|
const match = line.match(regex)
|
||||||
if (match) {
|
if (match) {
|
||||||
updates.push({
|
updates.push(entryProducer(match))
|
||||||
name: match[1],
|
|
||||||
currentVersion: match[2],
|
|
||||||
newVersion: match[3],
|
|
||||||
description: `${match[1]} ${match[2]} → ${match[3]}`
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +176,9 @@ Singleton {
|
|||||||
if (!distributionSupported || !pkgManager || updateCount === 0) return
|
if (!distributionSupported || !pkgManager || updateCount === 0) return
|
||||||
|
|
||||||
const terminal = Quickshell.env("TERMINAL") || "xterm"
|
const terminal = Quickshell.env("TERMINAL") || "xterm"
|
||||||
const updateCommand = `${pkgManager} -Syu && echo "Updates complete! Press Enter to close..." && read`
|
const params = packageManagerParams[pkgManager].upgradeSettings.params.join(" ")
|
||||||
|
const sudo = packageManagerParams[pkgManager].upgradeSettings.requiresSudo ? "sudo" : ""
|
||||||
|
const updateCommand = `${sudo} ${pkgManager} ${params} && echo "Updates complete! Press Enter to close..." && read`
|
||||||
|
|
||||||
updater.command = [terminal, "-e", "sh", "-c", updateCommand]
|
updater.command = [terminal, "-e", "sh", "-c", updateCommand]
|
||||||
updater.running = true
|
updater.running = true
|
||||||
@@ -149,4 +190,4 @@ Singleton {
|
|||||||
running: distributionSupported && pkgManager
|
running: distributionSupported && pkgManager
|
||||||
onTriggered: checkForUpdates()
|
onTriggered: checkForUpdates()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user