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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
local cairo = require "lgi".cairo
local gcolor = require "gears.color"
local gsurface = require "gears.surface"
local imagebox = require "ui.statusbar.panel.widgets.imagebox"
local phosphor = require "assets.phosphor"
local playerctl = require "services.playerctl"
local qnative = require "quarrel.native"
local qui = require "quarrel.ui"
local qvars = require "quarrel.vars"
local wibox = require "wibox"
local default_cover = phosphor.vinyl_record_fill
local default_text = "Nothing playing"
local function faded_cover(cover)
local surface = gsurface(cover)
local w,h = gsurface.get_size(surface)
local cr = cairo.Context(surface)
local pattern = gcolor(qvars.colors.bg .. "aa")
cr:rectangle(0, 0, w, h)
cr:set_source(pattern)
cr:fill_preserve()
return surface
end
local w_title = wibox.widget {
widget = wibox.widget.textbox,
text = "Nothing playing",
}
local w_artist = wibox.widget {
widget = wibox.container.background,
fg = qvars.colors.dim.fg,
{
widget = wibox.widget.textbox,
text = ""
}
}
local w_cover = wibox.widget {
widget = imagebox,
image = default_cover,
stylesheet = qui.recolor(qvars.colors.bright.black),
forced_height = qvars.char_height * 6 + qvars.big_padding * 2,
forced_width = qvars.expanded_bar_size - qvars.big_padding,
horizontal_fit_policy = "cover",
vertical_fit_policy = "cover",
valign = "center",
halign = "center"
}
local w_progress_bar = wibox.widget {
widget = wibox.widget.progressbar,
max_value = 0,
value = 0,
forced_height = qvars.char_height / 2,
forced_width = qvars.expanded_bar_size - (qvars.big_padding + qvars.big_padding * 2 + qvars.padding * 2) - (qvars.char_height / 1.25 + qvars.padding) * 3,
color = qvars.colors.yellow,
background_color = qvars.colors.black,
shape = qvars.shape,
}
local w_play_pause = qui.toggle {
widget = {
forced_height = qvars.char_height / 1.25,
forced_width = qvars.char_height / 1.25
},
off = phosphor.play_fill,
on = phosphor.pause_fill,
manual = true,
press = function()
playerctl:play_pause()
end
}
local w_skip_forward = qui.button {
widget = {
forced_height = qvars.char_height / 1.25,
forced_width = qvars.char_height / 1.25
},
image = phosphor.skip_forward_fill,
press = function()
playerctl:next()
end
}
local w_skip_back = qui.button {
widget = {
forced_height = qvars.char_height / 1.25,
forced_width = qvars.char_height / 1.25
},
image = phosphor.skip_back_fill,
press = function()
playerctl:previous()
end
}
local music = wibox.widget(qui.styled {
widget = wibox.container.background,
{
{
widget = wibox.container.background,
bg = qvars.colors.black
},
w_cover,
{
widget = wibox.container.margin,
margins = qvars.big_padding,
{
{
{
widget = wibox.container.background,
bg = qvars.colors.bg,
shape = qvars.shape,
{
widget = wibox.container.margin,
margins = qvars.padding,
{
{
widget = wibox.container.constraint,
width = qvars.expanded_bar_size - (qvars.big_padding + qvars.big_padding * 2 + qvars.padding * 2),
height = qvars.char_height,
{
widget = wibox.container.scroll.horizontal,
speed = 50,
step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth,
w_title
}
},
{
widget = wibox.container.constraint,
width = qvars.expanded_bar_size - (qvars.big_padding + qvars.big_padding * 2 + qvars.padding * 2),
height = qvars.char_height,
{
widget = wibox.container.scroll.horizontal,
speed = 50,
step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth,
w_artist
}
},
layout = wibox.layout.fixed.vertical
}
}
},
nil,
nil,
layout = wibox.layout.align.horizontal
},
nil,
{
widget = wibox.container.background,
bg = qvars.colors.bg,
shape = qvars.shape,
{
widget = wibox.container.margin,
margins = qvars.padding,
{
w_play_pause,
w_skip_back,
{
widget = wibox.container.place,
w_progress_bar
},
w_skip_forward,
layout = wibox.layout.fixed.horizontal,
spacing = qvars.padding
}
}
},
layout = wibox.layout.align.vertical
}
},
layout = wibox.layout.stack
}
})
awesome.connect_signal("services::playerctl::metadata", function(title, artist, album_path)
w_title.text = title ~= "" and qnative.decode_html(title) or default_text
w_artist.widget.text = qnative.decode_html(artist)
w_cover.image = faded_cover(album_path)
end)
awesome.connect_signal("services::playerctl::position", function(position, length)
w_progress_bar.value = position
w_progress_bar.max_value = length
end)
awesome.connect_signal("services::playerctl::no_players", function()
w_title = default_text
w_artist = ""
w_cover.image = default_cover
w_progress_bar.value = 0
w_progress_bar.max_value = 0
end)
awesome.connect_signal("services::playerctl::playback_status", function(playing)
w_play_pause:silent_press(playing)
end)
return music
|