You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thought of a way to auto update KDE Plasma Widgets. I don't use discover to update my system so this seemed a good way of providing an alternate way of delivering updates for plasma widgets/themes. Every widget or plasma theme uses metadata.json to provide info about the widget/theme. In the metadata.json file there is a version key, use this to check for a new version. Put this in your config setup or main.qml so that when the widget first runs it checks for updates, could auto update or prompt user to update. Only tested on github, not sure for gitlab or other platforms
property string updateURL:"https://raw.githubusercontent.com/txhammer68/pirateWeather/refs/heads/main/metadata.json"
property string updateCMD:"git clone https://github.com/TxHammer68/pirateWeather /tmp/pirateWeather/ && kpackagetool6 -t Plasma/Applet -u /tmp/pirateWeather/"
property double currentVersion:Plasmoid.metaData.version
property double updateVersion:0.0
property bool updateAvail:false
property string updateMsg:"Updated Version Ready "+"("+updateVersion+")"
Component.onCompleted:{
getData(updateURL)
updateAvail ? executable.exec(updateCMD):""
}
functiongetData(url) {
let xhr = new XMLHttpRequest()
xhr.open("GET", url,true)
xhr.responseType = 'json'
xhr.setRequestHeader('Content-Type', 'application/json')
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
let response = xhr.response
let data = response
processUpdateData(data)
}
}
}
}
xhr.send();
}
functionprocessUpdateData (data) {
updateVersion=data.KPlugin.Version
if (updateVersion > currentVersion) {
updateAvail=true
}
}
Plasma5Support.DataSource {
id: executable
engine: "executable"
connectedSources: []
onNewData: {
let exitCode = data["exit code"]
let exitStatus = data["exit status"]
let stdout = data["stdout"]
let stderr = data["stderr"]
exited(exitCode, exitStatus, stdout, stderr)
disconnectSource(sourceName) // cmd finished
}
functionexec(cmd) {
connectSource(cmd)
}
signal exited(int exitCode, int exitStatus, string stdout, string stderr)
}