@@ -24,7 +24,7 @@ local PLAY_ICON_NAME = PATH_TO_ICONS .. "/symbolic/actions/media-playback-sta
24
24
local STOP_ICON_NAME = PATH_TO_ICONS .. " /symbolic/actions/media-playback-stop-symbolic.svg"
25
25
local LIBRARY_ICON_NAME = PATH_TO_ICONS .. " /symbolic/places/folder-music-symbolic.svg"
26
26
27
- local FONT = ' Roboto Mono 18px '
27
+ local FONT = ' Roboto Condensed 16px '
28
28
29
29
local default_player = ' mpv'
30
30
@@ -72,13 +72,14 @@ local mpris_widget = wibox.widget {
72
72
73
73
local cover_art_widget = wibox .widget {
74
74
widget = wibox .widget .imagebox ,
75
- forced_height = 300 ,
75
+ forced_height = 0 ,
76
76
forced_width = 300 ,
77
77
resize_allowed = true ,
78
78
}
79
79
80
80
local metadata_widget = wibox .widget {
81
81
widget = wibox .widget .textbox ,
82
+ font = FONT ,
82
83
forced_height = 100 ,
83
84
forced_width = 300 ,
84
85
}
@@ -162,12 +163,19 @@ local function update_metadata(artist, current_song, progress, art_url)
162
163
-- poor man's urldecode
163
164
art_url = art_url :gsub (" file://" , " /" )
164
165
art_url = art_url :gsub (" %%(%x%x)" , function (x ) return string.char (tonumber (x , 16 )) end )
165
- cover_art_widget :set_image (art_url )
166
+
167
+ if art_url ~= nil and art_url ~= " " then
168
+ cover_art_widget .image = art_url
169
+ cover_art_widget .forced_height = 300
170
+ else
171
+ cover_art_widget .image = nil
172
+ cover_art_widget .forced_height = 0
173
+ end
166
174
end
167
175
168
176
local function worker ()
169
177
-- retrieve song info
170
- local current_song , artist , player_status , art_url
178
+ local current_song , artist , player_status , art_url , progress
171
179
172
180
local update_graphic = function (widget , stdout , _ , _ , _ )
173
181
local words = gears .string .split (stdout , ' ;' )
@@ -178,20 +186,24 @@ local function worker()
178
186
art_url = words [4 ]
179
187
180
188
if current_song ~= nil then
181
- if string.len (current_song ) > 30 then
182
- current_song = string.sub (current_song , 0 , 28 ) .. " .. "
189
+ if string.len (current_song ) > 40 then
190
+ current_song = string.sub (current_song , 0 , 38 ) .. " … "
183
191
end
184
192
end
185
193
186
194
if player_status == " Playing" then
187
195
icon .image = PLAY_ICON_NAME
188
196
widget .colors = { beautiful .widget_main_color }
189
- progress = tonumber (words [5 ]) / tonumber (words [6 ])
197
+ if words [5 ] ~= nil and words [6 ] ~= nil then
198
+ progress = tonumber (words [5 ]) / tonumber (words [6 ])
199
+ end
190
200
update_metadata (artist , current_song , progress , art_url )
191
201
elseif player_status == " Paused" then
192
202
icon .image = PAUSE_ICON_NAME
193
203
widget .colors = { beautiful .widget_main_color }
194
- progress = tonumber (words [5 ]) / tonumber (words [6 ])
204
+ if words [5 ] ~= nil and words [6 ] ~= nil then
205
+ progress = tonumber (words [5 ]) / tonumber (words [6 ])
206
+ end
195
207
update_metadata (artist , current_song , progress , art_url )
196
208
elseif player_status == " Stopped" then
197
209
icon .image = STOP_ICON_NAME
0 commit comments