mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-04 21:02:06 -04:00
plugins/desktop-widgets: create a new "desktop" widget plugin type
- Draggable per-monitor background layer widgets - Add basic dms version checks on plugins - Clock: built-in clock desktop plugin - dgop: built-in system monitor desktop plugin
This commit is contained in:
@@ -20,6 +20,11 @@ Singleton {
|
||||
property bool distributionSupported: false
|
||||
property string shellVersion: ""
|
||||
property string shellCodename: ""
|
||||
property string semverVersion: ""
|
||||
|
||||
function getParsedShellVersion() {
|
||||
return parseVersion(semverVersion);
|
||||
}
|
||||
|
||||
readonly property var archBasedUCSettings: {
|
||||
"listUpdatesSettings": {
|
||||
@@ -135,6 +140,18 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: semverDetection
|
||||
command: ["sh", "-c", `cd "${Quickshell.shellDir}" && if [ -f VERSION ]; then cat VERSION; fi`]
|
||||
running: true
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
semverVersion = text.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: codenameDetection
|
||||
command: ["sh", "-c", `cd "${Quickshell.shellDir}" && if [ -f CODENAME ]; then cat CODENAME; fi`]
|
||||
@@ -288,4 +305,86 @@ Singleton {
|
||||
return "SUCCESS: Now checking...";
|
||||
}
|
||||
}
|
||||
|
||||
function parseVersion(versionStr) {
|
||||
if (!versionStr || typeof versionStr !== "string")
|
||||
return {
|
||||
major: 0,
|
||||
minor: 0,
|
||||
patch: 0
|
||||
};
|
||||
|
||||
let v = versionStr.trim();
|
||||
if (v.startsWith("v"))
|
||||
v = v.substring(1);
|
||||
|
||||
const dashIdx = v.indexOf("-");
|
||||
if (dashIdx !== -1)
|
||||
v = v.substring(0, dashIdx);
|
||||
|
||||
const plusIdx = v.indexOf("+");
|
||||
if (plusIdx !== -1)
|
||||
v = v.substring(0, plusIdx);
|
||||
|
||||
const parts = v.split(".");
|
||||
return {
|
||||
major: parseInt(parts[0], 10) || 0,
|
||||
minor: parseInt(parts[1], 10) || 0,
|
||||
patch: parseInt(parts[2], 10) || 0
|
||||
};
|
||||
}
|
||||
|
||||
function compareVersions(v1, v2) {
|
||||
if (v1.major !== v2.major)
|
||||
return v1.major - v2.major;
|
||||
if (v1.minor !== v2.minor)
|
||||
return v1.minor - v2.minor;
|
||||
return v1.patch - v2.patch;
|
||||
}
|
||||
|
||||
function checkVersionRequirement(requirementStr, currentVersion) {
|
||||
if (!requirementStr || typeof requirementStr !== "string")
|
||||
return true;
|
||||
|
||||
const req = requirementStr.trim();
|
||||
let operator = "";
|
||||
let versionPart = req;
|
||||
|
||||
if (req.startsWith(">=")) {
|
||||
operator = ">=";
|
||||
versionPart = req.substring(2);
|
||||
} else if (req.startsWith("<=")) {
|
||||
operator = "<=";
|
||||
versionPart = req.substring(2);
|
||||
} else if (req.startsWith(">")) {
|
||||
operator = ">";
|
||||
versionPart = req.substring(1);
|
||||
} else if (req.startsWith("<")) {
|
||||
operator = "<";
|
||||
versionPart = req.substring(1);
|
||||
} else if (req.startsWith("=")) {
|
||||
operator = "=";
|
||||
versionPart = req.substring(1);
|
||||
} else {
|
||||
operator = ">=";
|
||||
}
|
||||
|
||||
const reqVersion = parseVersion(versionPart);
|
||||
const cmp = compareVersions(currentVersion, reqVersion);
|
||||
|
||||
switch (operator) {
|
||||
case ">=":
|
||||
return cmp >= 0;
|
||||
case ">":
|
||||
return cmp > 0;
|
||||
case "<=":
|
||||
return cmp <= 0;
|
||||
case "<":
|
||||
return cmp < 0;
|
||||
case "=":
|
||||
return cmp === 0;
|
||||
default:
|
||||
return cmp >= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user