From 6fd25ec5e0f3c3b64aad328ef1e86c4c433f761b Mon Sep 17 00:00:00 2001 From: Breizh Date: Sat, 13 Aug 2022 01:59:25 +0200 Subject: [PATCH] Correction temps i3blocks/mpd --- .i3blocks/mpd | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.i3blocks/mpd b/.i3blocks/mpd index e5811c8..1d915d6 100755 --- a/.i3blocks/mpd +++ b/.i3blocks/mpd @@ -21,8 +21,8 @@ declare -i SCROLL=50 I=0 declare -- artist song oldfile human_time() { - local seconds="${1:-0}" - if [[ "$seconds" -le 0 ]] + local seconds="${1}" + if [[ -z "$seconds" || "$seconds" -lt 0 ]] then echo "--:--" return @@ -163,12 +163,19 @@ do declare -i time_elapsed time_total time_left - time_elapsed="${o["time"]%:*}" - time_total="${o["time"]#*:}" - time_left="${time_total:-${o["duration"]%.*}} - ${time_elapsed:-${o["Time"]}}" + time_total="${o["Time"]:--1}" + if [[ "${o["state"]}" == "stop" ]] + then + time_elapsed=-1 + time_left=-1 + else + time_elapsed="${o["time"]%:*}" + time_left="${time_total} - ${time_elapsed}" + fi time="[$(human_time "${time_elapsed}") $(human_time "${time_left}") $(human_time "${time_total}")]" + # Nettoyage des chaînes de caractère pour pango bloc1="${bloc1//&/&}" bloc2="${bloc2//&/&}" bloc3="${bloc3//&/&}"