blob: 7c632be9c97c23dadbef8b80c39be2ae716f9804 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
pragma Singleton
import Quickshell
import Quickshell.Io
import QtQuick
Singleton {
id: root
property string file
property string artist
property string album
property string title
readonly property string coverPath: "/home/samn/Music/cover.jpg"
signal songChanged()
signal coverLoaded()
Process {
id: songProc
command: ["rmpc", "song"]
running: true
stdout: StdioCollector {
onStreamFinished: {
if (!this.text) {
root.file = ""
root.artist = ""
root.album = ""
root.title = ""
return
}
var oldFile = root.file
var obj = JSON.parse(this.text);
root.file = obj.file
root.artist = obj.metadata.artist
root.album = obj.metadata.album
root.title = obj.metadata.title
if (obj.file !== oldFile) {
root.songChanged()
coverProc.exec(["ffmpeg", "-y", "-i", "/home/samn/Music/" + obj.file, "-an", "-c:v", "copy", root.coverPath])
}
}
}
}
Process {
id: coverProc
running: false
onExited: root.coverLoaded()
}
Timer {
interval: 5000
running: true
repeat: true
onTriggered: songProc.running = true
}
}
|