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
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//&/&}"