From f8c8536ce3d82a2ee6e9fdc2e48840b0143db124 Mon Sep 17 00:00:00 2001 From: Sem Date: Sat, 18 Apr 2026 00:40:26 +0200 Subject: [PATCH] added a lil' fella --- quickshell/services/NowPlayingService.qml | 20 ++++++++++-- quickshell/shell.qml | 1 + quickshell/ui/NowPlaying.qml | 37 +++++++++++++++++++---- quickshell/ui/TopBar.qml | 2 ++ 4 files changed, 52 insertions(+), 8 deletions(-) diff --git a/quickshell/services/NowPlayingService.qml b/quickshell/services/NowPlayingService.qml index ac7101a..7f0e6a6 100644 --- a/quickshell/services/NowPlayingService.qml +++ b/quickshell/services/NowPlayingService.qml @@ -20,14 +20,23 @@ Item { root.artist = ""; root.title = ""; root.artUrl = ""; - root.isPlaying = false; return; } var parts = text.split("|||"); root.artist = parts[0] || ""; root.title = parts[1] || ""; root.artUrl = parts[2] || ""; - root.isPlaying = (parts[3] || "").trim() === "Playing"; + } + } + } + + Process { + id: playerCtlPlayingProc + command: ["playerctl", "status"] + stdout: StdioCollector { + onStreamFinished: { + var status = this.text.trim(); + root.isPlaying = (status === "Playing"); } } } @@ -39,5 +48,12 @@ Item { onTriggered: playerctlProc.running = true } + Timer { + interval: 1000 + running: true + repeat: true + onTriggered: playerCtlPlayingProc.running = true + } + Component.onCompleted: playerctlProc.running = true } diff --git a/quickshell/shell.qml b/quickshell/shell.qml index f0f9174..4a56ce6 100644 --- a/quickshell/shell.qml +++ b/quickshell/shell.qml @@ -56,6 +56,7 @@ ShellRoot { nowPlayingArtist: nowPlayingService.artist nowPlayingTitle: nowPlayingService.title nowPlayingArtUrl: nowPlayingService.artUrl + nowPlaying: nowPlayingService.isPlaying } } } diff --git a/quickshell/ui/NowPlaying.qml b/quickshell/ui/NowPlaying.qml index 90e49ca..d032939 100644 --- a/quickshell/ui/NowPlaying.qml +++ b/quickshell/ui/NowPlaying.qml @@ -10,6 +10,7 @@ Row { property string artist: "" property string title: "" property string artUrl: "" + property bool isPlaying: false property int maxTextLength: 50 property int numBands: 32 @@ -20,9 +21,20 @@ Row { return fullText.length > maxTextLength ? fullText.substring(0, maxTextLength - 3) + "..." : fullText; } + property string dancingLeft: "└(ಠ_ಠ )┐" + property string dancingRight: "┌( ಠ_ಠ)┘" + property string notDancing: "(ಠ ∩ ಠ)" + visible: title !== "" spacing: 6 + Text { + id: littleFella + text: root.dancingLeft + color: Colors.md3.primary + anchors.verticalCenter: parent.verticalCenter + } + //TODO add service that reads the data from cava // the fifo buffer is in /tmp/cava.fifo. Example data is: // 5;3;3;3;2;1;1;3;6;18;42;16;6;6;1;1;2;6;2;3;6;6;5;11;11;12;13;66;4;4;24;2;2;24;4;4;66;13;12;11;11;5;6;6;3;2;3;2;1;1;6;6;16;42;19;5;2;1;1;2;3;4;3;7; @@ -47,11 +59,24 @@ Row { // z: 1 } - Item { - id: titleArea - anchors.bottom: parent.bottom - width: titleText.implicitWidth - height: Math.max(titleText.implicitHeight, visualizer.height) + Timer { + interval: 400 + running: true + repeat: true + onTriggered: { + if (root.isPlaying) { + littleFella.text = littleFella.text === root.dancingLeft ? root.dancingRight : root.dancingLeft; + } else { + littleFella.text = root.notDancing; + } + } + } + + // Item { + // id: titleArea + // anchors.bottom: parent.bottom + // width: titleText.implicitWidth + // height: Math.max(titleText.implicitHeight, visualizer.height) // Canvas { // id: visualizer @@ -133,7 +158,7 @@ Row { // } // } // } - } + // } // CavaService { // id: cavaService diff --git a/quickshell/ui/TopBar.qml b/quickshell/ui/TopBar.qml index e81a7f4..3231046 100644 --- a/quickshell/ui/TopBar.qml +++ b/quickshell/ui/TopBar.qml @@ -20,6 +20,7 @@ Item { property string nowPlayingArtist: "" property string nowPlayingTitle: "" property string nowPlayingArtUrl: "" + property bool nowPlaying: false RowLayout { anchors.fill: parent @@ -44,6 +45,7 @@ Item { artist: root.nowPlayingArtist title: root.nowPlayingTitle artUrl: root.nowPlayingArtUrl + isPlaying: root.nowPlaying Layout.fillHeight: true Layout.alignment: Qt.AlignBottom }