diff --git a/.i3blocks/mpd b/.i3blocks/mpd
index a66565b..3266444 100755
--- a/.i3blocks/mpd
+++ b/.i3blocks/mpd
@@ -17,12 +17,12 @@ OUT=${COPROC[0]}
sed '/^OK/q' <&$OUT &>/dev/null
# Initialisation des valeurs par défaut et des fonctions
-declare -i SCROLL=50 I=0
+declare -i SCROLL=4time_left0 I=0
declare -- artist song oldfile
human_time() {
- local seconds="$1"
- if [[ "$seconds" -lt 0 ]]
+ local seconds="${1:-0}"
+ if [[ "$seconds" -le 0 ]]
then
echo "--:--"
return
@@ -159,13 +159,15 @@ do
fi
# Gestion du temps
- time_elapsed=$(human_time "${o["time"]%:*}")
- time_total=$(human_time "${o["time"]#*:}")
- time_left=$(human_time "$(( ${o["time"]#*:} - ${o["time"]%:*} ))")
- time="[${time_elapsed:---:--} ${time_left:---:--} ${time_total:---:--}]"
+ 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="[$(human_time ${time_elapsed}) $(human_time ${time_left}) $(human_time ${time_total})]"
# DEBUG
printf '%s%s%s%s%s\n' "$bloc1" "$bloc2" "$bloc3" "$bloc4" " $status$time"
done
-done