From 774d8880cdf7c3bb555eaa980fce4e9eeca1a34a Mon Sep 17 00:00:00 2001 From: chayleaf Date: Mon, 20 Feb 2023 22:48:21 +0700 Subject: [PATCH] mpris: fix potentially invalid seconds count on >1h media --- src/modules/mpris/mpris.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/mpris/mpris.cpp b/src/modules/mpris/mpris.cpp index d2837734..32896bb9 100644 --- a/src/modules/mpris/mpris.cpp +++ b/src/modules/mpris/mpris.cpp @@ -348,7 +348,7 @@ auto Mpris::getDynamicStr(const PlayerInfo& info, bool truncated, bool html) -> if (showAlbum) dynamic << album << " - "; if (showTitle) dynamic << title; if (showLength || showPos) { - dynamic << " "; + dynamic << ' '; if (html) dynamic << ""; dynamic << '['; if (showPos) { @@ -501,7 +501,7 @@ auto Mpris::getPlayerInfo() -> std::optional { std::chrono::microseconds len = std::chrono::microseconds(std::strtol(length_, nullptr, 10)); auto len_h = std::chrono::duration_cast(len); auto len_m = std::chrono::duration_cast(len - len_h); - auto len_s = std::chrono::duration_cast(len - len_m); + auto len_s = std::chrono::duration_cast(len - len_h - len_m); info.length = fmt::format("{:02}:{:02}:{:02}", len_h.count(), len_m.count(), len_s.count()); g_free(length_); } @@ -518,7 +518,7 @@ auto Mpris::getPlayerInfo() -> std::optional { std::chrono::microseconds len = std::chrono::microseconds(position_); auto len_h = std::chrono::duration_cast(len); auto len_m = std::chrono::duration_cast(len - len_h); - auto len_s = std::chrono::duration_cast(len - len_m); + auto len_s = std::chrono::duration_cast(len - len_h - len_m); info.position = fmt::format("{:02}:{:02}:{:02}", len_h.count(), len_m.count(), len_s.count()); } }