From 10aeeb71adf6a21b0612a115cf49f9a4062ff71c Mon Sep 17 00:00:00 2001 From: Artem Tarasov Date: Mon, 20 May 2024 20:20:56 +0200 Subject: [PATCH] handle absence of year in the metadata --- mpris-widget/init.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mpris-widget/init.lua b/mpris-widget/init.lua index 166c575..20fdc8d 100644 --- a/mpris-widget/init.lua +++ b/mpris-widget/init.lua @@ -246,7 +246,14 @@ local function worker(user_args) local update_metadata = function(meta) artist_widget:set_text(meta.artist) title_widget:set_text(meta.current_song) - metadata_widget:set_text(string.format('%s (%s)\n%s (%s/%s)', meta.album, meta.year, meta.current_song, duration(meta.position), duration(meta.length))) + + local s = meta.album; + if meta.year ~= nil and #meta.year == 4 then + s = s .. " (" .. meta.year .. ")" + end + s = s .. "\n" .. meta.current_song .. " (" .. duration(meta.position) .. "/" .. duration(meta.length) .. ")" + metadata_widget:set_text(s) + progress_widget.value = meta.progress -- poor man's urldecode