skeledance/plugin/contents/ui/main.qml
ltadeu6 10b3bbbf2e
feat: multi-player support + 5-line karaoke lyrics display
- get-playing.sh: iterates playerctl players, picks the one actually
  Playing; QML now calls this instead of bare playerctl metadata so
  a paused Spotify no longer blocks a playing YouTube from showing

- dancer.html: replace single lyric line with 5-slot karaoke display —
  active line (center) is full-brightness with theme-color glow; 2 lines
  before/after are progressively dimmed; slots fade out/in (0.18s/0.45s)
  when the active line advances

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 16:53:17 -03:00

56 lines
1.6 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
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
}
}
// 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) + ")"
)
}
}
}