skeledance/plugin/contents/ui/main.qml
ltadeu6 71845ff2a7
refactor: replace keybind toggle with config checkbox for skeleton visibility
Removes the pynput/curl-based shortcut approach in favour of a plain
Plasma wallpaper config checkbox (ShowSkeleton). QML reads the setting
on page load and on change, calling setShowSkeleton() in JS directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-10 15:00:44 -03:00

69 lines
2 KiB
QML

import QtQuick 2.0
import QtWebEngine 1.10
import org.kde.plasma.core
import org.kde.plasma.plasmoid
import org.kde.plasma.plasma5support as Plasma5Support
WallpaperItem {
id: root
function applyConfig() {
webView.runJavaScript("setShowSkeleton(" + Plasmoid.configuration.ShowSkeleton + ")")
}
Connections {
target: Plasmoid.configuration
function onShowSkeletonChanged() { applyConfig() }
}
WebEngineView {
id: webView
anchors.fill: parent
url: Qt.resolvedUrl("dancer.html")
backgroundColor: "#000814"
settings {
javascriptEnabled: true
localContentCanAccessFileUrls: true
localContentCanAccessRemoteUrls: true
localStorageEnabled: false
}
onContextMenuRequested: function(request) {
request.accepted = true
}
onLoadingChanged: function(loadRequest) {
if (loadRequest.status === WebEngineLoadRequest.LoadSucceededStatus)
applyConfig()
}
}
// Start CAVA on load
Plasma5Support.DataSource {
id: cavaStarter
engine: "executable"
connectedSources: ["bash " + Qt.resolvedUrl("cava-start.sh").toString().replace("file://", "") + " &"]
interval: 0
}
// Polls playerctl every 2s and injects music info into the page
Plasma5Support.DataSource {
id: musicSource
engine: "executable"
connectedSources: ["bash " + Qt.resolvedUrl("get-playing.sh").toString().replace("file://", "")]
interval: 2000
onNewData: function(sourceName, data) {
var raw = data["stdout"].trim()
var parts = raw.split("||")
var status = parts[0] || ""
var artist = status === "Playing" ? (parts[1] || "") : ""
var title = status === "Playing" ? (parts[2] || "") : ""
webView.runJavaScript(
"updateMusic(" + JSON.stringify(artist) + "," + JSON.stringify(title) + ")"
)
}
}
}