Correction temps i3blocks/mpd

This commit is contained in:
Breizh 2022-08-13 01:59:25 +02:00
parent b36e848cee
commit 6fd25ec5e0

View file

@ -21,8 +21,8 @@ declare -i SCROLL=50 I=0
declare -- artist song oldfile declare -- artist song oldfile
human_time() { human_time() {
local seconds="${1:-0}" local seconds="${1}"
if [[ "$seconds" -le 0 ]] if [[ -z "$seconds" || "$seconds" -lt 0 ]]
then then
echo "--:--" echo "--:--"
return return
@ -163,12 +163,19 @@ do
declare -i time_elapsed time_total time_left declare -i time_elapsed time_total time_left
time_elapsed="${o["time"]%:*}" time_total="${o["Time"]:--1}"
time_total="${o["time"]#*:}" if [[ "${o["state"]}" == "stop" ]]
time_left="${time_total:-${o["duration"]%.*}} - ${time_elapsed:-${o["Time"]}}" 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}")]" time="[$(human_time "${time_elapsed}") $(human_time "${time_left}") $(human_time "${time_total}")]"
# Nettoyage des chaînes de caractère pour pango
bloc1="${bloc1//&/&}" bloc1="${bloc1//&/&}"
bloc2="${bloc2//&/&}" bloc2="${bloc2//&/&}"
bloc3="${bloc3//&/&}" bloc3="${bloc3//&/&}"