aboutsummaryrefslogtreecommitdiff
path: root/roles/home/desktop/eww/panels/music.yuck
blob: 757efd5223dcee5825398e5c754e88659d0273a9 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
(defwidget music []
    (box :class "panel music"
        :orientation "h"
        :spacing 8
        :space-evenly false
        :height {128 + 16 + 4}

        (image
            :path song-cover
            :image-width 128
            :image-height 128
        )

        (box :class "right"
            :orientation "v"
            :spacing 0
            :space-evenly true
            :hexpand true

            (box :class "info"
                :orientation "v"
                :space-evenly false
                :valign "center"

                (tooltip {song.title}
                    (label :class "song-title"
                        :text {song.title}
                        :halign "start"
                        :truncate true
                    )
                )
                (tooltip {song.album}
                    (label :class "song-album"
                        :text {song.album}
                        :halign "start"
                        :truncate true
                    )
                )
                (tooltip {song.artist}
                    (label :class "song-artist"
                        :text {song.artist}
                        :halign "start"
                        :truncate true
                    )
                )
            )

            (box
                :valign "end"
                :space-evenly false

                (box :class "control"
                    :space-evenly false

                    (button :class "icon"
                        :width 36
                        :onclick `playerctl --player=cmus,firefox,%any previous`
                        
                        "󰒮"
                    )
                    (button :class "icon"
                        :onclick `playerctl --player=cmus,firefox,%any play-pause`
                        :width 36

                        { song.status == "Playing" ? "󰏤" : "󰐊" }
                    )
                    (button :class "icon"
                        :width 36
                        :onclick `playerctl --player=cmus,firefox,%any next`

                        "󰒭"
                    )
                )

                (scale
                    :hexpand true
                    :value {song-position}
                    :max {song.length/1000/1000}
                    ;:onchange `/home/c/seek.sh {}`
                )

                {formattime(round(song-position, 0), "%M:%S") + " / " + formattime(round(song.length/1000/1000, 0), "%M:%S")}

                (box :width 16)
            )
        )
    )
)

(deflisten song-cover
    `playerctl --player=cmus,firefox,%any -F metadata title | get-album-art`
)

(deflisten song
    `playerctl --player=cmus,firefox,%any -F metadata --format='{"title": "{{title}}", "album": "{{album}}", "artist": "{{artist}}", "status": "{{status}}", "length": "{{mpris:length}}"}'`
)

(defpoll song-position
    :interval "0.2s"
    `playerctl --player=cmus,firefox,%any position`
)