Skip to content

Instantly share code, notes, and snippets.

@txhammer68
Last active February 21, 2026 19:41
Show Gist options
  • Select an option

  • Save txhammer68/f78e95b957bb21e72e840a56cc896427 to your computer and use it in GitHub Desktop.

Select an option

Save txhammer68/f78e95b957bb21e72e840a56cc896427 to your computer and use it in GitHub Desktop.
Auto Update KDE Plasma Widgets/Themes

Auto-Update KDE Plasma Widgets/Themes

  • 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):""
    }
    
function getData(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();
}

 function processUpdateData (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
        }
        function exec(cmd) {
            connectSource(cmd)
        }
        signal exited(int exitCode, int exitStatus, string stdout, string stderr)
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment